status

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Package status maps the live status report onto the magus.status.v1alpha1 wire message and base64-encodes it for the dashboard's SSE stream.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeStatusEvent

func EncodeStatusEvent(r types.StatusReport, build types.BuildInfo) (string, error)

EncodeStatusEvent marshals a status snapshot to base64(protobuf) for a StreamStatus SSE `data:` line - the live-dashboard delivery. The JS client base64-decodes then Status.fromBinary.

Types

type ConnectService

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

ConnectService is the typed Connect surface over the SAME live status report the base64-SSE status frame serves. It is the full replacement for the removed hand-shaped JSON /api/v1/status route: the dashboard reads a single typed message (magus.status.v1alpha1.Status, plus observing_since and config on the GetStatus envelope) instead of parsing JSON. Read-only: it only reports, never mutates.

func NewConnectService

func NewConnectService(src statusSource, build types.BuildInfo, log *slog.Logger) *ConnectService

NewConnectService builds the StatusService Connect handler over src (the live report source, satisfied by *console.Service). build stamps the reporting binary's identity onto every snapshot, as the SSE status frame does.

func (*ConnectService) GetStatus

GetStatus returns the current live snapshot as a typed magus.status.v1alpha1.Status, plus the two static per-session fields (observing_since, config) on the response envelope - the typed replacement for the removed JSON /api/v1/status route, which carried the live status AND those static fields in one body.

func (*ConnectService) StreamStatus

StreamStatus pushes a snapshot on connect, then re-samples on a ticker and pushes again only when the encoded snapshot changes - the typed twin of the base64-SSE status frame. It returns when the client disconnects (ctx cancelled). A send error means the stream is gone; return it so Connect tears the RPC down.

type EventsHandler

type EventsHandler struct {
	handler.Base
	// contains filtered or unexported fields
}

EventsHandler serves GET /api/v1/events as a Server-Sent Events stream.

Events:

  • event: graph, data: {"seq": N} -- workspace graph changed (N is monotonic)
  • event: status, data: <base64 proto> -- pool state changed; payload is a base64 magus.status.v1alpha1.Status (see EncodeStatusEvent), pushed on connect and on change.
  • event: metrics, data: <base64 proto> -- current metrics as base64 OTLP (ExportMetricsServiceRequest); pushed on connect and on change when metrics is set.
  • comment-line heartbeat every heartbeat interval.

Clients refetch /api/v1/graph on a graph event; no diff is embedded. The graph channel is driven by invalidate; when it is nil only heartbeats (and status/metrics) are emitted. Status streaming is active only when version is non-empty; metrics only when metrics != nil.

func NewEventsHandler

func NewEventsHandler(src statusSource, build types.BuildInfo, metrics func(ctx context.Context) ([]byte, error), invalidate <-chan struct{}, heartbeat, statusInterval time.Duration, log *slog.Logger) *EventsHandler

NewEventsHandler returns the GET /api/v1/events SSE handler. build stamps (and gates via its version) the status frames; metrics, when non-nil, feeds the metrics channel; invalidate drives the graph channel; heartbeat and statusInterval override the default 25s / 2s periods (zero uses the defaults).

Jump to

Keyboard shortcuts

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