Skip to content

Commit 3533410

Browse files
author
Tihomir Surdilovic
authored
Merge pull request #33 from tsurdilo/addcompensation
[1.0.x] Workflow compensation impl
2 parents 4a10779 + b5b3fd9 commit 3533410

File tree

15 files changed

+219
-3
lines changed

15 files changed

+219
-3
lines changed

api/src/main/java/io/serverlessworkflow/api/interfaces/State.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,7 @@ public interface State {
4848

4949
List<Error> getOnErrors();
5050

51+
String getCompensatedBy();
52+
5153
Map<String, String> getMetadata();
5254
}

api/src/main/resources/schema/end/end.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
"type": "object",
2121
"$ref": "../produce/produceevent.json"
2222
}
23+
},
24+
"compensate": {
25+
"type": "boolean",
26+
"default": false,
27+
"description": "If set to true, triggers workflow compensation when before workflow executin completes. Default is false"
2328
}
2429
},
2530
"required": [

api/src/main/resources/schema/states/callbackstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"eventDataFilter": {
2525
"description": "Callback event data filter definition",
2626
"$ref": "../filters/eventdatafilter.json"
27+
},
28+
"usedForCompensation": {
29+
"type": "boolean",
30+
"default": false,
31+
"description": "If true, this state is used to compensate another state. Default is false"
2732
}
2833
},
2934
"required": [

api/src/main/resources/schema/states/defaultstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
"type": "object",
6565
"$ref": "../error/error.json"
6666
}
67+
},
68+
"compensatedBy": {
69+
"type": "string",
70+
"minLength": 1,
71+
"description": "Unique Name of a workflow state which is responsible for compensation of this state"
6772
}
6873
},
6974
"required": [

api/src/main/resources/schema/states/delaystate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@
1212
"timeDelay": {
1313
"type": "string",
1414
"description": "Amount of time (ISO 8601 format) to delay"
15+
},
16+
"usedForCompensation": {
17+
"type": "boolean",
18+
"default": false,
19+
"description": "If true, this state is used to compensate another state. Default is false"
1520
}
1621
},
1722
"required": [

api/src/main/resources/schema/states/foreachstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838
"workflowId": {
3939
"type": "string",
4040
"description": "Unique Id of a workflow to be executed for each of the elements of inputCollection"
41+
},
42+
"usedForCompensation": {
43+
"type": "boolean",
44+
"default": false,
45+
"description": "If true, this state is used to compensate another state. Default is false"
4146
}
4247
},
4348
"oneOf": [

api/src/main/resources/schema/states/injectstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@
1313
"type": "object",
1414
"description": "JSON object which can be set as states data input and can be manipulated via filters",
1515
"existingJavaType": "com.fasterxml.jackson.databind.JsonNode"
16+
},
17+
"usedForCompensation": {
18+
"type": "boolean",
19+
"default": false,
20+
"description": "If true, this state is used to compensate another state. Default is false"
1621
}
1722
},
1823
"required": [

api/src/main/resources/schema/states/operationstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"type": "object",
2525
"$ref": "../actions/action.json"
2626
}
27+
},
28+
"usedForCompensation": {
29+
"type": "boolean",
30+
"default": false,
31+
"description": "If true, this state is used to compensate another state. Default is false"
2732
}
2833
},
2934
"required": [

api/src/main/resources/schema/states/parallelstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
"type": "string",
2828
"default": "0",
2929
"description": "Used when completionType is set to 'n_of_m' to specify the 'N' value"
30+
},
31+
"usedForCompensation": {
32+
"type": "boolean",
33+
"default": false,
34+
"description": "If true, this state is used to compensate another state. Default is false"
3035
}
3136
},
3237
"required": [

api/src/main/resources/schema/states/subflowstate.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"workflowId": {
1818
"type": "string",
1919
"description": "Sub-workflow unique id."
20+
},
21+
"usedForCompensation": {
22+
"type": "boolean",
23+
"default": false,
24+
"description": "If true, this state is used to compensate another state. Default is false"
2025
}
2126
},
2227
"required": [

0 commit comments

Comments
 (0)