server

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2026 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package server wires the HTTP router for Oriel: a small JSON REST surface for actions, SSE channels for live data, and the embedded frontend.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HistoryPoint

type HistoryPoint struct {
	T    int64   `json:"t"` // unix milliseconds
	CPU  float64 `json:"cpu"`
	Mem  int64   `json:"mem"`
	Down bool    `json:"down,omitempty"`
}

HistoryPoint is one aggregate sample of total CPU% and memory at a moment. Down marks a tick where colima/docker was unreachable while the recorder was running — distinct from Oriel itself being offline, which records nothing at all and so leaves a time gap between points. (omitempty keeps the common "up" case compact and lets older persisted files load as up.)

type Job

type Job struct {
	ID    string
	Kind  string
	Title string
	// contains filtered or unexported fields
}

A Job is a long-running operation (prune, …) that runs on a background context decoupled from any request, so it survives client refresh/disconnect. Progress is buffered for replay and broadcast live to attached SSE subscribers, and the job can be cancelled. Progress comes in two forms: log lines (a few step messages) and a numeric counter (cur/total) that drives a progress bar.

type Outage

type Outage struct {
	Kind  string `json:"kind"`
	Start int64  `json:"start"` // unix ms
	End   int64  `json:"end"`   // unix ms
}

Outage is one recorded downtime, retained far longer than the 30-min pulse buffer. Kind is "down" (colima unreachable while we watched) or "offline" (Oriel itself was not running, inferred from a gap on restart).

type Reporter

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

Reporter is what a job's work function uses to report progress. Line adds a log message; Progress sets the cur/total counter (drives the bar).

func (Reporter) Line

func (r Reporter) Line(s string)

func (Reporter) Progress

func (r Reporter) Progress(cur, total int)

type Server

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

Server holds shared dependencies and implements http.Handler.

func New

func New(web fs.FS, version string) *Server

New constructs the router. web is the embedded frontend filesystem; version is the build version ("dev" for local builds, the release tag otherwise).

func (*Server) Close

func (s *Server) Close()

Close stops the recorder and persists the history + outage logs. Call on shutdown.

func (*Server) LogStartup added in v0.2.0

func (s *Server) LogStartup(url string)

LogStartup writes a one-line-per-fact config summary to the log on boot, plus a warning when the config looks like it will 403 behind a reverse proxy. Headless operators see this in journalctl and don't have to guess what's configured.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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