Documentation
¶
Overview ¶
Package events provides an in-process publish/subscribe bus used to push notify-only realtime updates to UI clients via WebSocket. Events carry only type/topic metadata; consumers refetch via REST to read current state.
Index ¶
Constants ¶
const ( TopicGlobalApps = "global:apps" TopicGlobalSettings = "global:settings" TopicGlobalUsers = "global:users" TopicGlobalRegistries = "global:registries" TopicGlobalAlerts = "global:alerts" TopicGlobalBackups = "global:backups" TopicGlobalDocker = "global:docker" TopicGlobalAudit = "global:audit" )
Topic constants for the global scopes. Per-app topics are formed via AppTopic.
Variables ¶
This section is empty.
Functions ¶
func TopicsForAudit ¶
TopicsForAudit returns the list of topics that should fire for a given audit category, action, and (optional) app slug. Used by the audit recorder to translate mutation events into bus publishes.
func TypeForCategory ¶
TypeForCategory returns the canonical event type string for an audit category, used as the "type" field in the WS frame.
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
Bus is a single-process fan-out bus. Safe for concurrent use.
func (*Bus) Publish ¶
Publish fans an event out to every subscriber whose filter accepts it. Never blocks: if a subscriber's buffer is full, the oldest event is discarded and the subscriber's stale flag is set.
func (*Bus) Subscribe ¶
Subscribe registers a new subscriber. filter is evaluated server-side at publish time so events that fail filter never reach the channel; pass nil to receive all events. The returned cancel function unsubscribes and closes the channel; calling it more than once is safe.
The returned read-only channel has buffer 64. On overflow, the oldest event is dropped and Stale() returns true so the handler can emit a synthetic resync frame.
type Event ¶
type Event struct {
Type string `json:"type"`
Topic string `json:"topic"`
ActorID *int64 `json:"actor_id,omitempty"`
Ts time.Time `json:"ts"`
}
Event is a single notify-only message broadcast on the bus. Type is a coarse classification (e.g. "app.changed", "app.status"). Topic identifies the resource scope (e.g. "app:foo", "global:settings"). No payload data ships in events; clients refetch the relevant REST resource.