Skip to content

Commit 16a5b2a

Browse files
authored
Merge pull request #859 from shital-orchestral/task-retry-model-branch
Added task retry model feature to task properties.
2 parents ca9f220 + 03fc9c6 commit 16a5b2a

File tree

5 files changed

+63
-5
lines changed

5 files changed

+63
-5
lines changed

modules/st2-auto-form/style.css

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,5 +482,3 @@
482482
}
483483

484484

485-
486-

modules/st2flow-details/orquesta-properties.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,11 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
6262
}
6363
}
6464

65+
getValue(value) {
66+
console.log("getValue called",value);
67+
if(!isNaN(value) && value!== '') value = parseInt(value,10);
68+
return value;
69+
}
6570
style = style
6671
joinFieldRef = React.createRef();
6772

@@ -100,6 +105,17 @@ export default class OrquestaTransition extends Component<TransitionProps, {}> {
100105
)
101106
}
102107
</Property>,
108+
<Property key="retry" name="Retry" description="Define the retry condition for the task execution." value={!!task.retry} onChange={value => this.handleTaskProperty('retry', value ? { when: '<% failed() %>' } : false)}>
109+
{
110+
task.retry && (
111+
<div className={this.style.propertyChild}>
112+
<StringField name="when" value={task.retry.when} className="when-title" onChange={value => this.handleTaskProperty([ 'retry', 'when' ], value)} spec={{'default':'enter expression'}} />
113+
<StringField name="count" value={task.retry.count} className="count-title" onChange={value => this.handleTaskProperty([ 'retry', 'count' ], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
114+
<StringField name="delay (seconds)" value={task.retry.delay} className="delay-title" onChange={value => this.handleTaskProperty([ 'retry', 'delay'], this.getValue(value))} spec={{'default':'enter expression or integer'}} />
115+
</div>
116+
)
117+
}
118+
</Property>,
103119
<Property key="with" name="With Items" description="Run an action or workflow associated with a task multiple times." value={!!task.with} onChange={value => this.handleTaskProperty('with', value ? { items: 'x in <% ctx(y) %>' } : false)}>
104120
{
105121
task.with && (

modules/st2flow-model/interfaces.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ export interface TaskInterface {
4040
items: string,
4141
concurrency?: string,
4242
};
43+
retry?: ?{
44+
when: string,
45+
count?: string,
46+
delay?: string,
47+
};
4348
join?: ?string;
4449
ref?: any;
4550
}

modules/st2flow-model/model-orquesta.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ type RawTask = {
8787
input?: Object,
8888
next?: Array<NextItem>,
8989
with?: string | Object,
90-
join?: string
90+
join?: string,
91+
retry?:string | Object
9192
};
9293

9394
type RawTasks = {
@@ -140,7 +141,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
140141
}
141142
}
142143

143-
const { action = '', input, 'with': _with, join } = task;
144+
const { action = '', input, 'with': _with,'retry': _retry, join } = task;
144145
const [ actionRef, ...inputPartials ] = `${action}`.split(' ');
145146

146147
// if (inputPartials.length) {
@@ -162,6 +163,7 @@ class OrquestaModel extends BaseModel implements ModelInterface {
162163
},
163164
with: typeof _with === 'string' ? { items: _with } : _with,
164165
join,
166+
retry: typeof _retry === 'string' ?{ when: _retry} : _retry,
165167
};
166168

167169
return retVal;

modules/st2flow-model/schemas/orquesta.json

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,43 @@
5151
}
5252
}
5353
},
54+
"retry": {
55+
"type": "object",
56+
"properties": {
57+
"when": {
58+
"type": "string",
59+
"minLength": 1
60+
},
61+
"count": {
62+
"oneOf": [
63+
{
64+
"type": "string",
65+
"minLength": 1
66+
},
67+
{
68+
"type": "integer",
69+
"minimum": 0
70+
}
71+
]
72+
},
73+
"delay": {
74+
"oneOf": [
75+
{
76+
"type": "string",
77+
"minLength": 1
78+
},
79+
{
80+
"type": "integer",
81+
"minimum": 0
82+
}
83+
]
84+
}
85+
},
86+
"required": [
87+
"count"
88+
],
89+
"additionalProperties": false
90+
},
5491
"input": {
5592
"oneOf": [
5693
{
@@ -327,4 +364,4 @@
327364
"type": "string"
328365
}
329366
}
330-
}
367+
}

0 commit comments

Comments
 (0)