notify

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

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

View Source
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).

View Source
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

View Source
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

func EnabledForUser(u *repo.User, kind string) bool

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 OrgRoom

func OrgRoom(orgID string) string

OrgRoom carries org-canvas changes (layout today).

func ProjectRoom

func ProjectRoom(projectID string) string

Types

type Notifier

type Notifier struct {
	// contains filtered or unexported fields
}

func New

func New(hub *websocket.Hub, store repo.Store) *Notifier

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) Org

func (n *Notifier) Org(orgID string)

Org signals that something on the org canvas changed.

func (*Notifier) Project

func (n *Notifier) Project(projectID string)

Project signals that something in a stack changed (statuses, runs, deploys).

func (*Notifier) Push

func (n *Notifier) Push(ctx context.Context, kind, title, body, link string)

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.

func (*Notifier) Server

func (n *Notifier) Server()

Server signals fresh host samples / daemon state.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL