operations

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package operations provides small operator-facing snapshots assembled from Chatz's already-running collaborators.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToAPI

func ToAPI(snapshot Snapshot) api.AdminReadiness

ToAPI projects a secret-free operations snapshot to the public admin wire contract.

Types

type BackupState

type BackupState string

BackupState explains whether an operator-provided backup marker proves a recent successful backup. It intentionally says nothing about archive contents: creation and integrity verification belong to the backup job.

const (
	BackupStateCurrent     BackupState = "current"
	BackupStateNotRecorded BackupState = "not_recorded"
	BackupStateStale       BackupState = "stale"
	BackupStateInvalid     BackupState = "invalid"
	BackupStateUnavailable BackupState = "unavailable"
)

type BackupStatus

type BackupStatus struct {
	State       BackupState
	CompletedAt time.Time
	Driver      db.Driver
}

BackupStatus is the safe subset of a backup marker shown to administrators.

type Config

type Config struct {
	AppVersion       string
	Commit           string
	DatabaseDriver   db.Driver
	BackupStatusPath string
	BackupMaxAge     time.Duration
	// contains filtered or unexported fields
}

Config selects the identity and local backup-marker policy for one process.

type MigrationReader

type MigrationReader interface {
	MigrationStatus(context.Context) (db.MigrationStatus, error)
}

MigrationReader lets readiness use the live DB handle while retaining a narrow, deterministic test seam.

type Service

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

Service reads non-secret operational facts from the live collaborators.

func New

func New(
	database MigrationReader,
	registry UpstreamHealthReader,
	config Config,
) (*Service, error)

New validates the static readiness configuration before serving requests.

func (*Service) Snapshot

func (s *Service) Snapshot(ctx context.Context) (Snapshot, error)

Snapshot reads the actual database ledger, current upstream tracker, and backup marker. A bad or missing marker is represented in BackupState rather than failing the whole operational page.

type Snapshot

type Snapshot struct {
	AppVersion      string
	Commit          string
	DatabaseDriver  db.Driver
	Migration       db.MigrationStatus
	Backup          BackupStatus
	UpstreamHealths []UpstreamHealth
}

Snapshot is the complete operational state rendered by the admin readiness page. It contains no credentials, file paths, prompt content, or provider response text.

type UpstreamHealth

type UpstreamHealth struct {
	Upstream           string
	State              UpstreamState
	LastOperation      string
	LastLatency        time.Duration
	LastSuccessAt      time.Time
	LastFailureAt      time.Time
	LastFailureClass   string
	ConsecutiveFailure int
}

UpstreamHealth is the operational subset of an upstream's last outcome.

type UpstreamHealthReader

type UpstreamHealthReader interface {
	ReadinessHealth() []UpstreamHealth
}

UpstreamHealthReader supplies a redacted, point-in-time upstream health snapshot without coupling readiness to the upstream configuration package.

type UpstreamState

type UpstreamState string

UpstreamState is the current client-visible condition of an upstream.

const (
	UpstreamStateUnknown  UpstreamState = "unknown"
	UpstreamStateHealthy  UpstreamState = "healthy"
	UpstreamStateDegraded UpstreamState = "degraded"
)

Jump to

Keyboard shortcuts

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