Sensors define a set of event dependencies (inputs) and triggers (outputs).
What is an event dependency?
A dependency is an event the sensor is waiting to happen. It is defined as "gateway-name:event-source-name".
What is a dependency group?
A dependency group is basically a group of event dependencies.
What is a circuit?
Circuit is any arbitrary boolean logic that can be applied on dependency groups.
What is a trigger?
How it works?
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
circuitdefined in spec. If the
circuitresolves to true, the triggers are fired. Sensor always waits for
circuitto resolve to true before firing triggers.
You may not want to fire all the triggers defined in sensor spec. For that, sensor offers
whenswitch on triggers. Basically
whenswitch is way to control when to fire certain trigger depending upon which dependency group is resolved.
After sensor fires triggers, it transitions into
completestate, 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:
|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
How to pass an event payload to a trigger?
Payload of an event can be passed to any trigger. The way it works is you define
parameters on trigger resource in sensor spec.
parameters define list of
event: the name of the event dependency
path: which is basically a key within event payload to look for
value: which is a default value if sensor can't find
pathin 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