maintenance

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package maintenance manages scoped, durable, auto-expiring maintenance windows.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrActive   = errors.New("maintenance: already active")
	ErrInactive = errors.New("maintenance: not active")
	ErrDenied   = errors.New("maintenance: denied")
	ErrExpired  = errors.New("maintenance: expired")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	DurablePath string
	MaxDuration time.Duration
	Clock       func() time.Time
}

Config configures Manager.

type EnterRequest

type EnterRequest struct {
	ID       string
	Reason   string
	Scope    Scope
	Duration time.Duration
	ActorID  string
	// CapabilityID is recorded for audit (verification done by caller).
	CapabilityID string
}

EnterRequest configures Enter.

type Manager

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

Manager tracks maintenance with optional file durability.

func New

func New(cfg Config) (*Manager, error)

New creates a Manager and loads durable state if present.

func (*Manager) Active

func (m *Manager) Active() bool

Active reports whether maintenance is in effect (auto-expires).

func (*Manager) Enter

func (m *Manager) Enter(req EnterRequest) (State, error)

Enter starts maintenance.

func (*Manager) Exit

func (m *Manager) Exit(actorID string) (State, error)

Exit ends maintenance.

func (*Manager) State

func (m *Manager) State() State

State returns a snapshot.

type Scope

type Scope struct {
	Claims []string `json:"claims,omitempty"`
	Tasks  []string `json:"tasks,omitempty"`
	All    bool     `json:"all,omitempty"`
}

Scope limits what maintenance affects.

type State

type State struct {
	ID        string    `json:"id"`
	Reason    string    `json:"reason"`
	Scope     Scope     `json:"scope"`
	EnteredAt time.Time `json:"entered_at"`
	ExpiresAt time.Time `json:"expires_at"`
	ActorID   string    `json:"actor_id"`
	Active    bool      `json:"active"`
}

State is durable maintenance state.

Jump to

Keyboard shortcuts

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