EventSource is a named inbound event channel. External systems dispatch events to a source by name, and the source routes them to one or more jobs or workflows via subscriptions. Each subscription can optionally filter on the event payload, so a single source can fan out to multiple targets selectively.
Event Sources vs Event Triggers
Event Sources and Event Triggers serve different purposes:- Event Sources are inbound channels for receiving external events and routing them to jobs or workflows. They are always-on endpoints that evaluate subscriptions on every dispatch.
- Event Triggers are durable waits used by workflow steps and runs to pause execution until a matching event arrives. They are created by in-flight runs and consumed once.
Event Sources push events into the system. Event Triggers wait for events from within the system.
EventSource Model
TheEventSource struct (defined in apps/strait/internal/domain/types.go) contains the following fields:
EventSubscription Model
AnEventSubscription binds an event source to a target (a job or workflow). When an event is dispatched to the source, each enabled subscription is evaluated and, if matched, triggers its target.
Subscriptions
A subscription connects a source to a target. Two target types are supported:job— When matched, a new job run is enqueued withtriggered_by: "event"and the dispatched payload.workflow— When matched, a new workflow run is triggered with the dispatched payload.
Filter Expressions
The optionalfilter_expr field on a subscription controls whether a dispatched event triggers that subscription. When present, the expression is evaluated against the event payload using eventfilter.Eval:
- If the expression evaluates to
true, the subscription fires. - If it evaluates to
false, the subscription is skipped for that event. - If
filter_expris omitted, the subscription fires on every dispatch.
Event Dispatch
ThePOST /v1/events/dispatch endpoint is the primary entry point for sending events into the system. The dispatch flow works as follows:
- The source is looked up by
namefrom the request body. - If the source is disabled, the dispatch is rejected.
- Each subscription on the source is evaluated:
- The
filter_expr(if present) is evaluated against the event payload. - Matching subscriptions trigger their target (enqueue a job run or start a workflow run).
- The
- The response includes the number of subscriptions that fired:
Schema Validation
The optionalschema field on an event source accepts a JSON Schema definition. When set, inbound event payloads can be validated against this schema before subscriptions are evaluated. This provides a contract between event producers and the source, catching malformed payloads early.
CRUD Lifecycle
Event sources and their subscriptions are managed through the following API operations:Related Concepts
- Event Triggers — Durable waits for events within workflow steps and runs.
- Jobs — The unit of work that event subscriptions can target.
- Workflows — Multi-step orchestrations that event subscriptions can target.