live

package
v0.26.1 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package live carries the "something changed" signal between nexus's mutating subsystems (registry, cron scheduler, rate-limit store) and the dashboard's live snapshot stream. It is a leaf package by design — registry / cron / ratelimit can import it without touching dashboard, and dashboard wires the listening side without each mutator needing to know dashboard exists.

Why not a channel directly: callers that mutate state (RegisterEndpoint, UpdateWorkerStatus, AttachResource) can't block on a slow dashboard, and would have to pre-allocate the right buffer size. A non-blocking Notify with select-default drop is the right shape for "tell whoever's listening; never stall the request path".

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Notifier

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

Notifier is the shared signal hub. Multiple subsystems call Notify(); multiple consumers (typically just streamLive, but the API supports more for future widgets) Subscribe to receive a nudge channel.

Notify is cheap (single mutex acquire + N non-blocking sends) and safe from any goroutine. The zero value is unusable — callers must go through New so the listeners slice is initialized.

func New

func New() *Notifier

New returns a fresh Notifier. Typically created once at app boot and threaded into each mutating subsystem via SetChangeHook (or the equivalent setter on each package).

func (*Notifier) Notify

func (n *Notifier) Notify()

Notify wakes every current subscriber whose channel has buffer room. Subscribers whose channel already has a pending nudge are left alone — coalescing N rapid mutations into one wake-up is the whole point. Never blocks the caller.

func (*Notifier) Subscribe

func (n *Notifier) Subscribe() (<-chan struct{}, func())

Subscribe registers a new listener and returns its nudge channel plus a cancel func. The channel has buffer 1 so a single pending notify is held even when the subscriber is busy. Cancel removes the listener and closes the channel; subsequent Notify calls skip it.

Cancel is safe to call multiple times.

Jump to

Keyboard shortcuts

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