Realtime events
SimpleDeploy keeps the dashboard fresh without polling by broadcasting tiny notify-only events over a single per-tab WebSocket. REST stays the source of truth: the server says “something on topic X changed, refetch it” and the UI calls the same loadX() it already used on first mount.
Architecture
Section titled “Architecture”[handler/worker] -> audit.Recorder.Record() --+ +-> events.Bus.Publish() -> per-conn filter -> WS frame[handler/worker] -> events.Bus.Publish() -----+
[WS conn] -> realtime.svelte.js -> registry[topic].forEach(refetch)[mount] -> registry.register(topic, refetchFn)[unmount] -> registry.unregister(...)Components
Section titled “Components”internal/events/bus.gois the in-process bus. Subscribers get a buffered channel and an unsubscribe function. On overflow the oldest event is dropped and a stale flag is set so the WS handler can emit a syntheticresyncframe.internal/events/topics.godefines the topic constants and the audit-category-to-topic mapping.internal/audit/recorder.gowraps every mutation, then publishes the matching topics best-effort (publish errors never block or fail the originating change).internal/api/events_ws.goupgradesGET /api/events, applies a per-connection topic filter, gatessubframes on the caller’s role anduser_app_access, pings every 30s, and re-checks authorization every 60s.ui/src/lib/stores/realtime.svelte.jsopens one WebSocket per tab, queues subscribes until open, and re-subscribes plus refetches all registered fns after every reconnect.
Topics
Section titled “Topics”| Topic | Sent on |
|---|---|
app:<slug> |
compose, env, endpoint, lifecycle, deploy, backup, status flips |
global:apps |
new/removed apps, status flips |
global:settings |
system settings, gitsync config, audit retention |
global:users |
users, role changes, access grants/revokes, API keys |
global:registries |
registry CRUD |
global:alerts |
webhooks, alert rules |
global:backups |
any backup config change; backup and restore runs starting and finishing |
global:docker |
docker prune actions |
global:audit |
every audit-recorded mutation |
Frame format
Section titled “Frame format”Client to server (JSON):
{"op":"sub","topic":"app:foo"}{"op":"unsub","topic":"app:foo"}{"op":"ping"}Server to client:
{"type":"app.changed","topic":"app:foo","ts":"..."}{"type":"resync","topic":"*"}{"op":"err","topic":"app:foo","reason":"forbidden"}{"op":"pong"}No payload data ever ships in events. The UI runs its existing REST refetch when a frame arrives.
Authorization
Section titled “Authorization”Topic ACL is computed when the WS opens. super_admin sees every global topic; everyone else sees global:apps, global:backups, global:alerts plus app:<slug> for any slug they have user_app_access on. A sub for a forbidden topic returns {op:"err", reason:"forbidden"}. An event about one app (Event.App set, never sent to clients) is delivered only to users who can view that app, on any topic: the backup scheduler publishes backup.run on both app:<slug> and global:backups when a run starts and finishes, and a user with access to other apps does not learn that this app’s backups ran. When an access or user audit event affects the connected user, the server closes the socket so the client reconnects with fresh authz.
The upgrade requires a matching Origin (host and port) or Sec-Fetch-Site: same-origin, like the log sockets (checkWebSocketOrigin, see Auth). Every 60s the socket re-runs wsAuthStillValid: if the user is gone, their role changed, or the session token or API key used to connect is no longer valid, it closes with code 1008. app: topics the user lost access to are dropped with an err frame. The app log, deploy log and process log sockets run the same 60s check and close on failure.
Non-goals
Section titled “Non-goals”- No event replay, no sequence numbers, no payload bodies.
- No multi-replica fan-out (single binary).
- Existing log streaming WebSockets and
connection.svelte.jshealth pinger are unchanged.