Skip to content

Commit fa51403

Browse files
committed
Added a new until property to any event consumption strategies
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
1 parent 7539516 commit fa51403

File tree

4 files changed

+68
-9
lines changed

4 files changed

+68
-9
lines changed

dsl-reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,8 +1489,9 @@ Represents the configuration of an event consumption strategy.
14891489
| Property | Type | Required | Description |
14901490
|----------|:----:|:--------:|-------------|
14911491
| all | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for all defined events before resuming execution.<br>*Required if `any` and `one` have not been set.* |
1492-
| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.<br>*Required if `all` and `one` have not been set.* |
1492+
| any | [`eventFilter[]`](#event-filter) | `no` | Configures the workflow to wait for any of the defined events before resuming execution.<br>*Required if `all` and `one` have not been set.*<br>*If empty, listens to all incoming events, and requires `until` to be set.* |
14931493
| one | [`eventFilter`](#event-filter) | `no` | Configures the workflow to wait for the defined event before resuming execution.<br>*Required if `all` and `any` have not been set.* |
1494+
| until | `string`<br>[`eventConsumptionStrategy`](#event-consumption-strategy) | `no` | Configures the [runtime expression](dsl.md#runtime-expressions) condition or the events that must be consumed to stop listening.<br>*Only applies if `any` has been set, otherwise ignored.* |
14941495

14951496
### Event Properties
14961497

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
document:
2+
dsl: '1.0.0-alpha1'
3+
namespace: test
4+
name: listen-to-any
5+
version: '0.1.0'
6+
do:
7+
- callDoctor:
8+
listen:
9+
to:
10+
any: []
11+
until: ( . | length ) > 3 #wait until 3 events have been consumed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
document:
2+
dsl: '1.0.0-alpha1'
3+
namespace: test
4+
name: listen-to-any
5+
version: '0.1.0'
6+
do:
7+
- callDoctor:
8+
listen:
9+
to:
10+
any:
11+
- with:
12+
type: com.fake-hospital.vitals.measurements.temperature
13+
data: ${ .temperature > 38 }
14+
- with:
15+
type: com.fake-hospital.vitals.measurements.bpm
16+
data: ${ .bpm < 60 or .bpm > 100 }
17+
until:
18+
one:
19+
with:
20+
type: com.fake-hospital.patient.checked-out

schema/workflow.yaml

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,14 +1196,41 @@ $defs:
11961196
$ref: '#/$defs/eventFilter'
11971197
required: [ all ]
11981198
- title: AnyEventConsumptionStrategy
1199-
properties:
1200-
any:
1201-
type: array
1202-
title: AnyEventConsumptionStrategyConfiguration
1203-
description: A list containing any of the events to consume.
1204-
items:
1205-
$ref: '#/$defs/eventFilter'
1206-
required: [ any ]
1199+
oneOf:
1200+
- properties:
1201+
any:
1202+
type: array
1203+
title: AnyEventConsumptionStrategyConfiguration
1204+
description: A list containing any of the events to consume.
1205+
items:
1206+
$ref: '#/$defs/eventFilter'
1207+
minItems: 1
1208+
until:
1209+
oneOf:
1210+
- type: string
1211+
title: AnyEventUntilCondition
1212+
description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening.
1213+
- $ref: '#/$defs/eventConsumptionStrategy'
1214+
title: AnyEventUntilConsumed
1215+
description: The strategy that defines the event(s) to consume to stop listening.
1216+
required: [ any ]
1217+
- properties:
1218+
any:
1219+
type: array
1220+
title: AnyEventConsumptionStrategyConfiguration
1221+
description: A list containing any of the events to consume.
1222+
items:
1223+
$ref: '#/$defs/eventFilter'
1224+
maxItems: 0
1225+
until:
1226+
oneOf:
1227+
- type: string
1228+
title: AnyEventUntilCondition
1229+
description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening.
1230+
- $ref: '#/$defs/eventConsumptionStrategy'
1231+
title: AnyEventUntilConsumed
1232+
description: The strategy that defines the event(s) to consume to stop listening.
1233+
required: [ any, until ]
12071234
- title: OneEventConsumptionStrategy
12081235
properties:
12091236
one:

0 commit comments

Comments
 (0)