Skip to content

Commit

Permalink
Added a new until property to any event consumption strategies
Browse files Browse the repository at this point in the history
Signed-off-by: Charles d'Avernas <charles.davernas@neuroglia.io>
  • Loading branch information
cdavernas committed Aug 28, 2024
1 parent 7539516 commit fa51403
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 9 deletions.
3 changes: 2 additions & 1 deletion dsl-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -1489,8 +1489,9 @@ Represents the configuration of an event consumption strategy.
| Property | Type | Required | Description |
|----------|:----:|:--------:|-------------|
| 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.* |
| 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.* |
| 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.* |
| 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.* |
| 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.* |

### Event Properties

Expand Down
11 changes: 11 additions & 0 deletions examples/listen-to-any-until-condition.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
document:
dsl: '1.0.0-alpha1'
namespace: test
name: listen-to-any
version: '0.1.0'
do:
- callDoctor:
listen:
to:
any: []
until: ( . | length ) > 3 #wait until 3 events have been consumed
20 changes: 20 additions & 0 deletions examples/listen-to-any-until-consumed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
document:
dsl: '1.0.0-alpha1'
namespace: test
name: listen-to-any
version: '0.1.0'
do:
- callDoctor:
listen:
to:
any:
- with:
type: com.fake-hospital.vitals.measurements.temperature
data: ${ .temperature > 38 }
- with:
type: com.fake-hospital.vitals.measurements.bpm
data: ${ .bpm < 60 or .bpm > 100 }
until:
one:
with:
type: com.fake-hospital.patient.checked-out
43 changes: 35 additions & 8 deletions schema/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1196,14 +1196,41 @@ $defs:
$ref: '#/$defs/eventFilter'
required: [ all ]
- title: AnyEventConsumptionStrategy
properties:
any:
type: array
title: AnyEventConsumptionStrategyConfiguration
description: A list containing any of the events to consume.
items:
$ref: '#/$defs/eventFilter'
required: [ any ]
oneOf:
- properties:
any:
type: array
title: AnyEventConsumptionStrategyConfiguration
description: A list containing any of the events to consume.
items:
$ref: '#/$defs/eventFilter'
minItems: 1
until:
oneOf:
- type: string
title: AnyEventUntilCondition
description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening.
- $ref: '#/$defs/eventConsumptionStrategy'
title: AnyEventUntilConsumed
description: The strategy that defines the event(s) to consume to stop listening.
required: [ any ]
- properties:
any:
type: array
title: AnyEventConsumptionStrategyConfiguration
description: A list containing any of the events to consume.
items:
$ref: '#/$defs/eventFilter'
maxItems: 0
until:
oneOf:
- type: string
title: AnyEventUntilCondition
description: A runtime expression condition evaluated after consuming an event and which determines whether or not to continue listening.
- $ref: '#/$defs/eventConsumptionStrategy'
title: AnyEventUntilConsumed
description: The strategy that defines the event(s) to consume to stop listening.
required: [ any, until ]
- title: OneEventConsumptionStrategy
properties:
one:
Expand Down

0 comments on commit fa51403

Please sign in to comment.