- Diagrams
- Flows
- PubSub Flow
PubSub Flow
The EventPublisher bridges internal lifecycle events to the NATS PUBSUB stream. Subscribers — the dashboard, the SDKs, consumer groups — receive notifications but never write to the database from consumption. The database remains the source of truth.
Not every topic reaches the bridge inline. system.* and topic:{name} are published in-process, but events:{name} and entity:{type}.{id}.{event} are written as transactional outbox rows in the same transaction as the event and handed to the bridge later by the outbox worker (issue #487). The subject mapping is the same either way — only the caller differs:
| Internal topic | NATS subject |
|---|---|
system.run.{id}.completed | public.{environmentId}.system.run.{id}.completed |
events:{name} | public.{environmentId}.events.{name} |
entity:{type}.{id}.{event} | public.{environmentId}.entity.{type}.{id}.{event} |
topic:{name} | public.{environmentId}.topic.{name} |
Live subscribers get an ephemeral consumer per subject pattern, with optional replay up to 1000 messages and CEL filter support. Consumer groups keep durable membership in the consumer_groups and consumer_members tables so one member receives each message.