Skip to content

Commit

Permalink
Merge pull request #826 from fjtirado/Fix_#677
Browse files Browse the repository at this point in the history
[Fix #677] Atomic produce and consume actions
  • Loading branch information
cdavernas authored Mar 20, 2024
2 parents 9f79f8f + 30c8fec commit 7ae6420
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 99 deletions.
1 change: 0 additions & 1 deletion examples/README_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,6 @@ events:
- contextAttributeName: accountId
- name: ConfirmationCompletedEvent
type: payment.confirmation
kind: produced

```

Expand Down
19 changes: 11 additions & 8 deletions examples/event-based-service-invocation.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@
{
"name": "make-vet-appointment",
"source": "VetServiceSource",
"type": "events.vet.appointments",
"kind": "produced"
"type": "events.vet.appointments"
},
{
"name": "vet-appointment-info",
"source": "VetServiceSource",
"type": "events.vet.appointments",
"kind": "consumed"
"type": "events.vet.appointments"
}
],
"states": [
Expand All @@ -26,10 +24,15 @@
"actions": [
{
"name": "make-appointment-action",
"eventRef": {
"produceEventRef": "make-vet-appointment",
"data": "${ .patientInfo }",
"consumeEventRef": "vet-appointment-info"
"publish": {
"event": "make-vet-appointment",
"data": "${ .patientInfo }"
}
},
{
"name": "wait-appointement-confirmation",
"subscribe": {
"event": "vet-appointment-info"
},
"actionDataFilter": {
"results": "${ .appointmentInfo }"
Expand Down
6 changes: 2 additions & 4 deletions examples/purchase-order-deadline.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,11 @@
},
{
"name": "order-finished-event",
"type": "my.company.orders",
"kind": "produced"
"type": "my.company.orders"
},
{
"name": "order-cancelled-event",
"type": "my.company.orders",
"kind": "produced"
"type": "my.company.orders"
}
],
"functions": [
Expand Down
3 changes: 1 addition & 2 deletions examples/send-cloudevent-on-workflow-completion.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
"events": [
{
"name": "provisioning-complete-event",
"type": "provisionCompleteType",
"kind": "produced"
"type": "provisionCompleteType"
}
],
"functions": [
Expand Down
9 changes: 0 additions & 9 deletions schema/events.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,6 @@
"type": "string",
"description": "CloudEvent type"
},
"kind": {
"type": "string",
"enum": [
"consumed",
"produced"
],
"description": "Defines the CloudEvent as either 'consumed' or 'produced' by the workflow. Default is 'consumed'",
"default": "consumed"
},
"correlation": {
"type": "array",
"description": "CloudEvent correlation definitions",
Expand Down
60 changes: 40 additions & 20 deletions schema/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,9 +413,13 @@
"description": "References a function to be invoked",
"$ref": "#/definitions/functionref"
},
"eventRef": {
"description": "References a `produce` and `consume` reusable event definitions",
"$ref": "#/definitions/eventref"
"publish": {
"description": "Publish an event",
"$ref": "#/definitions/publish"
},
"subscribe": {
"description": "Subscribe to an event channel",
"$ref": "#/definitions/subscribe"
},
"subFlowRef": {
"description": "References a sub-workflow to invoke",
Expand Down Expand Up @@ -468,7 +472,13 @@
{
"required": [
"name",
"eventRef"
"publish"
]
},
{
"required": [
"name",
"subscribe"
]
},
{
Expand Down Expand Up @@ -521,30 +531,21 @@
}
]
},
"eventref": {
"publish": {
"type": "object",
"description": "Event References",
"description": "Publish an event",
"properties": {
"produceEventRef": {
"event": {
"type": "string",
"description": "Reference to the unique name of a 'produced' event definition",
"description": "Reference to the unique name of a 'published' event definition",
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
},
"consumeEventRef": {
"type": "string",
"description": "Reference to the unique name of a 'consumed' event definition",
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
},
"consumeEventTimeout": {
"type": "string",
"description": "Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout"
},
"data": {
"type": [
"string",
"object"
],
"description": "If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'produceEventRef'. If object type, a custom object to become the data (payload) of the event referenced by 'produceEventRef'."
"description": "If string type, an expression which selects parts of the states data output to become the data (payload) of the event referenced by 'publish'. If object type, a custom object to become the data (payload) of the event referenced by 'publish'."
},
"contextAttributes": {
"type": "object",
Expand All @@ -556,7 +557,26 @@
},
"additionalProperties": false,
"required": [
"produceEventRef"
"event", "data"
]
},
"subscribe": {
"type": "object",
"description": "Subscribe to an event channel",
"properties": {
"event": {
"type": "string",
"description": "Reference to the unique name of a 'subscribed' event definition",
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
},
"timeout": {
"type": "string",
"description": "Maximum amount of time (ISO 8601 format) to wait for the result event. If not defined it should default to the actionExecutionTimeout"
}
},
"additionalProperties": false,
"required": [
"event"
]
},
"subflowref": {
Expand Down Expand Up @@ -1690,7 +1710,7 @@
"name",
"type",
"action",
"eventRef"
""
]
},
"else": {
Expand Down
Loading

0 comments on commit 7ae6420

Please sign in to comment.