Skip to content

Commit 3be14b9

Browse files
jorgenjJorgen Johnsontsurdilo
authored
Update eventDataFilter to call out that the entire event can be accessed (#349)
* Update eventDataFilter to make entire cloud-event accessible. Signed-off-by: Jorgen Johnson <[email protected]> * Small text fixes and Roadmap update Signed-off-by: Tihomir Surdilovic <[email protected]> Co-authored-by: Jorgen Johnson <[email protected]> Co-authored-by: Tihomir Surdilovic <[email protected]>
1 parent 596e9cf commit 3be14b9

File tree

6 files changed

+29
-10
lines changed

6 files changed

+29
-10
lines changed

comparisons/comparison-brigade.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ start: LogEventData
398398
events:
399399
- name: execEvent
400400
type: exec
401+
dataOnly: false
401402
functions:
402403
- name: consoleFunction
403404
type: console
@@ -408,7 +409,7 @@ states:
408409
- eventRefs:
409410
- execEvent
410411
eventDataFilter:
411-
results: "${ .event }"
412+
toStateData: "${ .event }"
412413
actions:
413414
- name: eventInfoAction
414415
functionRef:
@@ -490,7 +491,7 @@ states:
490491
- eventRefs:
491492
- execEvent
492493
eventDataFilter:
493-
data: "${ .event }"
494+
toStateData: "${ .event }"
494495
actions:
495496
- name: helloAction
496497
actionDataFilter:
@@ -565,6 +566,7 @@ start: ExecEventState
565566
events:
566567
- name: execEvent
567568
type: exec
569+
dataOnly: false
568570
- name: nextEvent
569571
type: next
570572
kind: produced
@@ -579,7 +581,7 @@ states:
579581
- execEvent
580582
actions: []
581583
eventDataFilter:
582-
data: "${ .execEvent }"
584+
toStateData: "${ .execEvent }"
583585
transition:
584586
nextState: NextEventState
585587
produceEvents:
@@ -597,7 +599,7 @@ states:
597599
- eventRefs:
598600
- nextEvent
599601
eventDataFilter:
600-
data: "${ .nextEvent }"
602+
toStateData: "${ .nextEvent }"
601603
actions:
602604
- name: consoleLogAction
603605
functionRef:

examples/README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,8 @@ filters what is selected to be the state data output which then becomes the work
317317
"onEvents": [{
318318
"eventRefs": ["GreetingEvent"],
319319
"eventDataFilter": {
320-
"data": "${ .data.greet }"
320+
"data": "${ .greet }",
321+
"toStateData": "${ .greet }"
321322
},
322323
"actions":[
323324
{
@@ -363,7 +364,8 @@ states:
363364
- eventRefs:
364365
- GreetingEvent
365366
eventDataFilter:
366-
data: "${ .data.greet }"
367+
data: "${ .greet }"
368+
toStateData: "${ .greet }"
367369
actions:
368370
- functionRef:
369371
refName: greetingFunction
@@ -3224,7 +3226,7 @@ the data for an hour, send report, and so on.
32243226
}
32253227
],
32263228
"eventDataFilter": {
3227-
"data": "${ .readings }"
3229+
"toStateData": "${ .readings }"
32283230
}
32293231
}
32303232
],
@@ -3307,7 +3309,7 @@ states:
33073309
- functionRef:
33083310
refName: LogReading
33093311
eventDataFilter:
3310-
data: "${ .readings }"
3312+
toStateData: "${ .readings }"
33113313
end: true
33123314
- name: GenerateReport
33133315
type: operation

roadmap/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ _Status description:_
3131
| ✔️| Add subflow actions `version` property | [spec doc](../specification.md) |
3232
| ✔️| Renamed `schemaVersion` to `specVersion` and it is now a required parameter | [spec doc](../specification.md) |
3333
| ✔️| Add GraphQL support for function definitions | [spec doc](../specification.md) |
34+
| ✔️| Added "dataOnly" property to Event Definitions (allow event data filters to access entire event) | [spec doc](../specification.md) |
3435
| 🚩 | Workflow invocation bindings | |
3536
| 🚩 | CE Subscriptions & Discovery | |
3637
| 🚩 | Error types | [issue](https://github.com/serverlessworkflow/specification/issues/200) |

schema/events.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@
6161
},
6262
"additionalItems": false
6363
},
64+
"dataOnly": {
65+
"type": "boolean",
66+
"default": true,
67+
"description": "If `true`, only the Event payload is accessible to consuming Workflow states. If `false`, both event payload and context attributes should be accessible "
68+
},
6469
"metadata": {
6570
"$ref": "common.json#/definitions/metadata",
6671
"description": "Metadata information"

schema/workflow.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,11 +1679,11 @@
16791679
"properties": {
16801680
"data": {
16811681
"type": "string",
1682-
"description": "Workflow expression that filters of the event data (payload)"
1682+
"description": "Workflow expression that filters the received event/payload (default: '${ . }')"
16831683
},
16841684
"toStateData": {
16851685
"type": "string",
1686-
"description": " Workflow expression that selects a state data element to which the event payload should be added/merged into. If not specified, denotes, the top-level state data element."
1686+
"description": " Workflow expression that selects a state data element to which the filtered event should be added/merged into. If not specified, denotes, the top-level state data element."
16871687
}
16881688
},
16891689
"additionalProperties": false,

specification.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,10 @@ Here is an example using an event filter:
536536
<img src="media/spec/event-data-filter-example1.png" height="400px" alt="Event Data Filter Example"/>
537537
</p>
538538

539+
Note that the data input to the Event data filters depends on the `dataOnly` property of the associated [Event definition](#Event-Definition).
540+
If this property is not defined (has default value of `true`), Event data filter expressions are evaluated against the event payload (the CloudEvents `data` attribute only). If it is set to
541+
`false`, the expressions should be evaluated against the entire CloudEvent (including its context attributes).
542+
539543
#### Using multiple data filters
540544

541545
As [Event states](#Event-State) can take advantage of all defined data filters. In the example below, we define
@@ -1934,6 +1938,7 @@ defined via the `parameters` property in [function definitions](#FunctionRef-Def
19341938
| type | CloudEvent type | string | yes |
19351939
| kind | Defines the event is either `consumed` or `produced` by the workflow. Default is `consumed` | enum | no |
19361940
| [correlation](#Correlation-Definition) | Define event correlation rules for this event. Only used for consumed events | array | no |
1941+
| dataOnly | If `true` (default value), only the Event payload is accessible to consuming Workflow states. If `false`, both event payload and context attributes should be accessible | boolean | no |
19371942
| [metadata](#Workflow-Metadata) | Metadata information | object | no |
19381943

19391944
<details><summary><strong>Click to view example definition</strong></summary>
@@ -2138,6 +2143,10 @@ says that these events must all have a context attribute named "department" with
21382143
This allows developers to write orchestration workflows that are specifically targeted to patients that are in the hospital urgent care unit,
21392144
for example.
21402145

2146+
The `dataOnly` property deals with what Event data is accessible by the consuming Workflow states.
2147+
If its value is `true` (default value), only the Event payload is accessible to consuming Workflow states.
2148+
If `false`, both Event payload and context attributes should be accessible.
2149+
21412150
#### Correlation Definition
21422151

21432152
| Parameter | Description | Type | Required |

0 commit comments

Comments
 (0)