Events module
Source: modules/events/.
At a glance
Section titled “At a glance”| CLI | shc events |
| Subcommands | 1 |
| HTTP endpoints | see the route reference |
| Events emitted | see the event reference |
| Error codes | see the error code reference |
| Service classes | EventStreamService |
| Cross-module deps | — |
Source layout
Section titled “Source layout”modules/events/├── command.go├── router.go├── service.go├── models.go└── commands/CLI entry points
Section titled “CLI entry points”shc events— stream and view system events
HTTP API
Section titled “HTTP API”Routes are listed in the generated route reference; request/response notes live in the API reference.
Responsibilities
Section titled “Responsibilities”The events module is the live event fan-out for the running
daemon. It takes two upstream sources of data — Docker events and audit
events — and multiplexes them to two downstream consumers:
- SSE clients (the UI,
shc events, external integrations) via the SSE broker insubsystems/impl/sse_broker.go, sharded by tenant on channels likeevents:<tenant>. - Internal subscribers inside the process (e.g. the deployment tracker, live-progress logic) via channel-based subscriptions registered with the module.
The module is functional, not class-heavy:
BroadcastDockerEvent(event)— dedups by a short hash of(ts, action, container, node), caps the seen-set atconfig.EventDedupCacheSize(default 10000), publishes to SSE, then pushes to every internal subscriber channel.BroadcastAuditEvent(event)— publishes to SSE (no dedup; audit events are assumed unique by primary key).FilterEvent(...)— shared filter logic used by CLI and SSE alike.EventStreamServiceowns theStartAuditPollergoroutine that periodically polls theaudittable for rows the daemon didn’t see in-process (covers cross-node audit events in a cluster).
What the events module does not own: the Docker event source
itself (that is subsystems/impl/docker_events.go), SSE transport (that
is subsystems/impl/sse_broker.go), or persistence (audit rows are owned
by the audit module). This module is a pure
distribution layer sitting in front of both.
See also: architecture/events/event-bus.md for the broader real-time layer.
shc@docs:~$