Skip to content

Commit

Permalink
[Fix #677] Charles comments
Browse files Browse the repository at this point in the history
Signed-off-by: Francisco Javier Tirado Sarti <ftirados@redhat.com>
  • Loading branch information
fjtirado committed Mar 8, 2024
1 parent a19d3a0 commit 9c0c7d2
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 44 deletions.
8 changes: 4 additions & 4 deletions examples/event-based-service-invocation.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@
"actions": [
{
"name": "make-appointment-action",
"produceEventRef": {
"name": "make-vet-appointment",
"publish": {
"event": "make-vet-appointment",
"data": "${ .patientInfo }"
}
},
{
"name": "wait-appointement-confirmation",
"consumeEventRef": {
"name": "vet-appointment-info"
"subscribe": {
"event": "vet-appointment-info"
},
"actionDataFilter": {
"results": "${ .appointmentInfo }"
Expand Down
34 changes: 17 additions & 17 deletions schema/workflow.json
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@
"description": "References a function to be invoked",
"$ref": "#/definitions/functionref"
},
"produceEventRef": {
"description": "References a `produce` reusable event definition",
"$ref": "#/definitions/produceeventref"
"publish": {
"description": "Publish an event",
"$ref": "#/definitions/publish"
},
"consumeEventRef": {
"description": "References a `consume` reusable event definition",
"$ref": "#/definitions/consumeeventref"
"subscribe": {
"description": "Subscribe to an event channel",
"$ref": "#/definitions/subscribe"
},
"subFlowRef": {
"description": "References a sub-workflow to invoke",
Expand Down Expand Up @@ -472,13 +472,13 @@
{
"required": [
"name",
"produceEventRef"
"publish"
]
},
{
"required": [
"name",
"consumeEventRef"
"subscribe"
]
},
{
Expand Down Expand Up @@ -531,21 +531,21 @@
}
]
},
"produceeventref": {
"publish": {
"type": "object",
"description": "Publish an event",
"properties": {
"name": {
"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])*$"
},
"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 @@ -560,16 +560,16 @@
"name", "data"
]
},
"consumeeventref": {
"subscribe": {
"type": "object",
"description": "Waits for an event",
"description": "Subscribe to an event channel",
"properties": {
"name": {
"event": {
"type": "string",
"description": "Reference to the unique name of a 'consumed' event definition",
"description": "Reference to the unique name of a 'subscribed' event definition",
"pattern": "^[a-z0-9](-?[a-z0-9])*$"
},
"consumeEventTimeout": {
"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"
}
Expand Down
45 changes: 22 additions & 23 deletions specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -3968,22 +3968,21 @@ functionRef:

</details>

Actions specify invocations of services or other workflows during workflow execution.
Service invocation can be done in three different ways:
An action can:

* Reference [functions definitions](#Function-Definition) by its unique name using the `functionRef` property.
* Reference a [event definitions](#Event-Definition) via the `produceEventRef` property in order to publish that event.
* Reference a [event definitions](#Event-Definition) via the `consumeEventRef` property in order to consume that event.
* Publish an event [event definitions](#Event-Definition) via the `publish` property.
* Subscribe to an event [event definitions](#Event-Definition) via the `subscribe` property.
* Reference a sub-workflow invocation via the `subFlowRef` property.

Note that `functionRef`, `eventRef`, and `subFlowRef` are mutually exclusive, meaning that only one of them can be
Note that `functionRef`, `publish`, `subscribe` and `subFlowRef` are mutually exclusive, meaning that only one of them can be
specified in a single action definition.

The `name` property specifies the action name.

In the event-based scenario a service, or a set of services we want to invoke are not exposed via a specific resource URI for example, but can only be invoked via an event.
In that case, an event definition might be referenced via its `produceEventRef` property.
Also, if there is the need to consume an event within a set of actions (for example, wait for the result of a previous action invocation) an event definition might be referenced via its `consumeEventRef` property.
In that case, an event definition might be referenced via its `publish` property.
Also, if there is the need to consume an event within a set of actions (for example, wait for the result of a previous action invocation) an event definition might be referenced via its `susbcribe` property.

The `sleep` property can be used to define time periods that workflow execution should sleep
before and/or after function execution. It can have two properties:
Expand Down Expand Up @@ -4110,14 +4109,14 @@ In addition, functions that are invoked async do not propagate their errors to t
workflow state, meaning that any errors that happen during their execution cannot be handled in the workflow states
onErrors definition. Note that errors raised during functions that are invoked async should not fail workflow execution.

##### ProduceEventRef Definition
##### Publish Definition

Publish an event.

| Parameter | Description | Type | Required |
| --- | --- | --- | --- |
| [name](#Event-Definition) | Reference to the unique name of an event definition. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
| data | 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`. | string or object | yes |
| [event](#Event-Definition) | Reference to the unique name of an event definition. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
| data | 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`. | string or object | yes |
| contextAttributes | Add additional event extension context attributes to the trigger/produced event | object | no |

<details><summary><strong>Click to view example definition</strong></summary>
Expand All @@ -4133,8 +4132,8 @@ Publish an event.

```json
{
"produceEventRef": {
"name": "make-vet-appointment",
"publish": {
"event": "make-vet-appointment",
"data": "${ .patientInfo }",
}
}
Expand All @@ -4144,8 +4143,8 @@ Publish an event.
<td valign="top">

```yaml
produceEventRef:
name: make-vet-appointment
publish:
event: make-vet-appointment
data: "${ .patientInfo }"
```

Expand All @@ -4155,22 +4154,22 @@ produceEventRef:

</details>

Publish an [event definition](#Event-Definition) referenced via the `name` property.
Publish an [event definition](#Event-Definition) referenced via the `event` property.

The `data` property can have two types: string or object. If it is of string type, it is an expression that can select parts of state data
to be used as payload of the event referenced by `produceEventRef`. If it is of object type, you can define a custom object to be the event payload.
to be used as payload of the event referenced by `publish`. If it is of object type, you can define a custom object to be the event payload.

The `contextAttributes` property allows you to add one or more [extension context attributes](https://github.com/cloudevents/spec/blob/main/cloudevents/spec.md#extension-context-attributes)
to the trigger/produced event.

##### ConsumeEventRef Definition
##### Susbscribe Definition

Wait for an event to arrive.

| Parameter | Description | Type | Required |
| --- | --- | --- | --- |
| [name](#Event-Definition) | Reference to the unique name of an event definition. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
| consumeEventTimeout | Maximum amount of time (ISO 8601 format literal or expression) to wait for the consume event. If not defined it be set to the [actionExecutionTimeout](#Workflow-Timeout-Definition) | string | no |
| [event](#Event-Definition) | Reference to the unique name of an event definition. Must follow the [Serverless Workflow Naming Convention](#naming-convention) | string | yes |
| timeout | Maximum amount of time (ISO 8601 format literal or expression) to wait for the consume event. If not defined it be set to the [actionExecutionTimeout](#Workflow-Timeout-Definition) | string | no |

<details><summary><strong>Click to view example definition</strong></summary>
<p>
Expand All @@ -4185,7 +4184,7 @@ Wait for an event to arrive.

```json
{
"consumeEventRef": {
"subscribe": {
"name": "approved-appointment",
}
}
Expand All @@ -4196,7 +4195,7 @@ Wait for an event to arrive.

```yaml
eventRef:
consumeEventRef: approved-appointment
subscribe: approved-appointment
```

Expand All @@ -4206,9 +4205,9 @@ eventRef:

</details>

Consumes an [event definition](#Event-Definition) referenced via the `name` property.
Consumes an [event definition](#Event-Definition) referenced via the `event` property.

The `consumeEventTimeout` property defines the maximum amount of time (ISO 8601 format literal or expression) to wait for the result event. If not defined it should default to the [actionExecutionTimeout](#Workflow-Timeout-Definition).
The `timeout` property defines the maximum amount of time (ISO 8601 format literal or expression) to wait for the result event. If not defined it should default to the [actionExecutionTimeout](#Workflow-Timeout-Definition).
If the event defined by the `name` property is not received in that set time, action invocation should raise an error that can be handled in the states `onErrors` definition.

##### SubFlowRef Definition
Expand Down

0 comments on commit 9c0c7d2

Please sign in to comment.