control

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package control defines the overmind<->worker control-channel wire format.

Index

Constants

View Source
const (
	AckAccepted       = "accepted"
	AckUnknownAgent   = "unknown_agent"
	AckAlreadyPending = "already_pending"
)

AdminAck statuses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Abort

type Abort struct {
	Reason string `json:"reason"`
	Flee   bool   `json:"flee"`
}

Abort tells a worker to stop now; Flee requests undock/flee first.

type AdminAck

type AdminAck struct {
	AgentID string `json:"agent_id"`
	Status  string `json:"status"`
	Detail  string `json:"detail,omitempty"`
}

AdminAck is the overmind's reply to an AdminRequest.

type AdminRequest

type AdminRequest struct {
	AgentID string `json:"agent_id"`
}

AdminRequest asks the overmind to change fleet membership for one agent. Sent by an admin client (dashboard backend) instead of a Hello; the connection receives one AdminAck and closes.

type Assign

type Assign struct {
	TaskID string            `json:"task_id"`
	Script string            `json:"script"`
	Params map[string]string `json:"params,omitempty"`
}

Assign tells a worker to run a one-shot task: resolve Script via the worker's script search path, substitute Params ($KEY$) into it, then run it once in place of the idle behavior. Completion is reported back via an Event (Kind "task_done" / "task_failed").

type Decoder

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

Decoder reads newline-delimited JSON envelopes.

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

NewDecoder returns a Decoder reading from r.

func (*Decoder) Decode

func (d *Decoder) Decode() (Envelope, error)

Decode reads the next envelope, returning io.EOF when the stream ends.

type Encoder

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

Encoder writes newline-delimited JSON envelopes. Safe for concurrent use by multiple goroutines.

func NewEncoder

func NewEncoder(w io.Writer) *Encoder

NewEncoder returns an Encoder writing to w.

func (*Encoder) Encode

func (e *Encoder) Encode(env Envelope) error

Encode marshals env to one JSON line and flushes.

type Envelope

type Envelope struct {
	Type    Type            `json:"type"`
	AgentID string          `json:"agent_id"`
	Payload json.RawMessage `json:"payload,omitempty"`
}

Envelope is the framed wire unit; one Envelope is one NDJSON line.

func NewEnvelope

func NewEnvelope(t Type, agentID string, payload any) (Envelope, error)

NewEnvelope marshals payload and wraps it with the given type and agent id.

func (Envelope) Into

func (e Envelope) Into(v any) error

Into unmarshals the envelope payload into v.

type Event

type Event struct {
	Kind      string `json:"kind"`
	Detail    string `json:"detail"`
	Timestamp string `json:"timestamp"`
}

Event is a notable worker-side occurrence (action result, danger signal).

type Hello

type Hello struct {
	AgentID string `json:"agent_id"`
	Role    string `json:"role"`
	Station string `json:"station"`
	PID     int    `json:"pid"`
	// Build identity of the worker binary (buildinfo.Get). Omitted by a
	// pre-feature worker, which the overmind treats as "unknown"/legacy.
	Version   string `json:"version,omitempty"`
	Commit    string `json:"commit,omitempty"`
	BuiltAt   string `json:"built_at,omitempty"` // RFC3339
	CodeDirty bool   `json:"code_dirty,omitempty"`
	Modified  bool   `json:"modified,omitempty"` // raw vcs.modified — cosmetic
}

Hello is the first message a worker sends after connecting.

type Status

type Status struct {
	System           string  `json:"system"`
	POI              string  `json:"poi"`
	Docked           bool    `json:"docked"`
	Hull             float64 `json:"hull"`
	MaxHull          float64 `json:"max_hull"`
	Fuel             float64 `json:"fuel"`
	MaxFuel          float64 `json:"max_fuel"`
	Credits          float64 `json:"credits"`
	CargoUsed        float64 `json:"cargo_used"`
	CargoCapacity    float64 `json:"cargo_capacity"`
	StandingBehavior string  `json:"standing_behavior"`
	ActiveTaskID     string  `json:"active_task_id"`
	// Activity is a short human-readable description of the unit of work the
	// standing role is currently doing (e.g. "Mission Steel Plate Order",
	// "Rescuing haul-3"). Empty when idle. Produced by the role goroutine and
	// read by the heartbeat goroutine via a shared atomic on WorkerDispatch.
	Activity   string `json:"activity,omitempty"`
	FactionID  string `json:"faction_id,omitempty"`
	FactionTag string `json:"faction_tag,omitempty"`
	Drained    bool   `json:"drained,omitempty"`
	// Disconnected reports that the worker's game-server connection is currently
	// down (it is reconnecting via the fleet-wide reconnect gate). It keeps
	// heartbeating to the overmind over the control socket throughout. The
	// supervisor uses this to avoid restarting a worker that is already
	// self-healing: a restart forces a fresh login that cannot succeed during a
	// per-IP rate-limit block and deepens it. Omitted (false) means connected,
	// so an older worker binary that never sets it is treated as connected.
	Disconnected bool   `json:"disconnected,omitempty"`
	Timestamp    string `json:"timestamp"`
}

Status is a worker heartbeat snapshot.

type Type

type Type string

Type identifies a control message kind.

const (
	TypeHello       Type = "hello"
	TypeStatus      Type = "status"
	TypeEvent       Type = "event"
	TypeAbort       Type = "abort"
	TypePause       Type = "pause"
	TypeResume      Type = "resume"
	TypeAssign      Type = "assign"
	TypeDrain       Type = "drain"
	TypeAdminRemove Type = "admin_remove"
	TypeAdminReadd  Type = "admin_readd"
	TypeAdminAck    Type = "admin_ack"
)

Jump to

Keyboard shortcuts

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