Sensors define a set of event dependencies (inputs) and triggers (outputs).
-
A dependency is an event the sensor is waiting to happen. It is defined as "gateway-name:event-source-name".
-
A dependency group is basically a group of event dependencies.
-
Circuit is any arbitrary boolean logic that can be applied on dependency groups.
-
Refer Triggers.
-
Once the sensor receives an event from gateway either over HTTP or through NATS, it validates the event against dependencies defined in sensor spec. If the event is expected, then it is marked as a valid event and the dependency is marked as resolved.
-
If you haven't defined dependency groups, sensor basically waits for all dependencies to resolve and then kicks off triggers in sequence. If filters are defined, sensor applies the filter on target event and if events pass the filters, triggers are fired.
-
If you have defined dependency groups, sensor upon receiving an event evaluates the group to which the event belongs to and marks the group as resolved if all other event dependencies in the group are already resolved.
-
Whenever a dependency group is resolved, sensor evaluates the
circuit
defined in spec. If thecircuit
resolves to true, the triggers are fired. Sensor always waits forcircuit
to resolve to true before firing triggers. -
You may not want to fire all the triggers defined in sensor spec. For that, sensor offers
when
switch on triggers. Basicallywhen
switch is way to control when to fire certain trigger depending upon which dependency group is resolved. -
After sensor fires triggers, it transitions into
complete
state, increments completion counter and initializes it's state back to running and start the process all over again. Any event that is received in-between are stored on the internal queue.
Note: If you don't provide dependency groups and circuit
, sensor performs an AND
operation on event dependencies.
There are 3 types of filters that you can apply on event payload:
Type | Description |
---|---|
Time | Filters the signal based on time constraints |
EventContext | Filters metadata that provides circumstantial information about the signal. |
Data | Describes constraints and filters for payload |
-
filters: time: start: "2016-05-10T15:04:05Z07:00" stop: "2020-01-02T15:04:05Z07:00"
-
filters: context: source: host: amazon.com contentType: application/json
-
filters: data: - path: bucket type: string value: argo-workflow-input
Payload of an event can be passed to any trigger. The way it works is you define parameters
on trigger resource in sensor spec.
The parameters
define list of
src
-event
: the name of the event dependencypath
: which is basically a key within event payload to look forvalue
: which is a default value if sensor can't findpath
in event payload.
dest
: destination key within trigger spec whose corresponding value needs to be replaced with value from event payload
- Pass complete event payload to trigger example
- Extract particular value from event payload and pass to trigger example
You can find sensor examples here