Skip to content

Commit db1b5ca

Browse files
authored
Merge pull request #997 from neuroglia-io/feat-listen-any-events-until
Added a new `until` property to `any` event consumption strategies
2 parents e64b3dd + 2463bd5 commit db1b5ca

File tree

6 files changed

+98
-9
lines changed

6 files changed

+98
-9
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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: []
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
document:
2+
dsl: '1.0.0-alpha1'
3+
namespace: test
4+
name: listen-to-any
5+
version: '0.1.0'
6+
do:
7+
do:
8+
- callDoctor:
9+
listen:
10+
to:
11+
any: []
12+
until:
13+
any: []
14+
until: ${ ($context.events | length) == 3 }

dsl-reference.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1580,8 +1580,9 @@ Represents the configuration of an event consumption strategy.
15801580
| Property | Type | Required | Description |
15811581
|----------|:----:|:--------:|-------------|
15821582
| 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.* |
1583-
| 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.* |
1583+
| 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.* |
15841584
| 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.* |
1585+
| 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.* |
15851586

15861587
### Event Properties
15871588

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: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,14 +1309,47 @@ $defs:
13091309
$ref: '#/$defs/eventFilter'
13101310
required: [ all ]
13111311
- title: AnyEventConsumptionStrategy
1312-
properties:
1313-
any:
1314-
type: array
1315-
title: AnyEventConsumptionStrategyConfiguration
1316-
description: A list containing any of the events to consume.
1317-
items:
1318-
$ref: '#/$defs/eventFilter'
1319-
required: [ any ]
1312+
oneOf:
1313+
- properties:
1314+
any:
1315+
type: array
1316+
title: AnyEventConsumptionStrategyConfiguration
1317+
description: A list containing any of the events to consume.
1318+
items:
1319+
$ref: '#/$defs/eventFilter'
1320+
minItems: 1
1321+
until:
1322+
oneOf:
1323+
- type: string
1324+
title: AnyEventUntilCondition
1325+
description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening.
1326+
- allOf:
1327+
- $ref: '#/$defs/eventConsumptionStrategy'
1328+
title: AnyEventUntilConsumed
1329+
description: The strategy that defines the event(s) to consume to stop listening.
1330+
- properties:
1331+
until: false
1332+
required: [ any ]
1333+
- properties:
1334+
any:
1335+
type: array
1336+
title: AnyEventConsumptionStrategyConfiguration
1337+
description: A list containing any of the events to consume.
1338+
items:
1339+
$ref: '#/$defs/eventFilter'
1340+
maxItems: 0
1341+
until:
1342+
oneOf:
1343+
- type: string
1344+
title: AnyEventUntilCondition
1345+
description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening.
1346+
- allOf:
1347+
- $ref: '#/$defs/eventConsumptionStrategy'
1348+
title: AnyEventUntilConsumed
1349+
description: The strategy that defines the event(s) to consume to stop listening.
1350+
- properties:
1351+
until: false
1352+
required: [ any, until ]
13201353
- title: OneEventConsumptionStrategy
13211354
properties:
13221355
one:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy