Documentation
¶
Overview ¶
Package notify pushes "something changed" events to browsers over the hamr websocket hub, and records events in the in-app notification center. Websocket events carry no data, clients react by re-fetching the authed HTTP endpoints they already render from, so the socket never needs its own auth story beyond the session.
Index ¶
Constants ¶
const ( RoomContainers = "containers" RoomServer = "server:local" RoomNotifications = "notifications" // RoomFlows carries the traffic sampler's tick. It is global rather than // per-stack: the sampler reads conntrack for the whole host and would have // to look up every tile's stack to fan out. Canvases showing traffic join // it and re-fetch their own status endpoint. RoomFlows = "flows" )
Room names browsers join (see frontend/static/js/live.js).
const ( KindDeployFailed = "deploy_failed" KindDeployDone = "deploy_done" KindCronFailed = "cron_failed" KindImageUpdate = "image_update" )
Notification kinds; each is gated by a "notify.<kind>" settings row.
Variables ¶
var Kinds = []struct { Kind string Label string DefaultOn bool }{ {KindDeployFailed, "Deployment failed", true}, {KindCronFailed, "Cron run failed", true}, {KindDeployDone, "Deployment succeeded", false}, {KindImageUpdate, "New image version", true}, }
Kinds lists every kind with its label and default state (for settings UI and gating). deploy_done is opt-in noise; failures default on.
Functions ¶
func EnabledForUser ¶
EnabledForUser reports whether one person wants a kind.
There is deliberately no instance-wide setting: who gets told about a failed deploy is a personal choice, and a server-level default only created the question of whether an admin's switch outranks yours. An untouched account falls back to the kind's built-in default (failures on, successes off).
func ProjectRoom ¶
Types ¶
type Notifier ¶
type Notifier struct {
// contains filtered or unexported fields
}
func (*Notifier) Containers ¶
func (n *Notifier) Containers()
Containers signals container state changes.
func (*Notifier) Flows ¶
func (n *Notifier) Flows()
Flows signals a fresh inter-tile traffic sample.
func (*Notifier) Project ¶
Project signals that something in a stack changed (statuses, runs, deploys).
func (*Notifier) Push ¶
Push fans an event out to every active user who wants this kind, one row each, then nudges open notification centers. Old entries are pruned past 30 days.
Callers are background workers (deploy engine, cron runner) with no current user, so recipients are enumerated from the store rather than taken from a request.