Documentation
¶
Overview ¶
Package fleet models worker liveness and compatibility without supervising worker processes or implementing queue delivery semantics.
Index ¶
- Constants
- Variables
- type Capability
- type Compatibility
- type CompatibilityState
- type DrainState
- type Heartbeat
- type HeartbeatDisposition
- type HeartbeatValidationError
- type Projection
- type ProjectionSnapshot
- type ProtocolRange
- type ProtocolVersion
- type QueueMetrics
- type QueueSnapshot
- type Registry
- func (r *Registry) RegisterTelemetry(meter metric.Meter, now func() time.Time, staleAfter time.Duration) (metric.Registration, error)
- func (r *Registry) Snapshot(now time.Time, staleAfter time.Duration) RegistrySnapshot
- func (r *Registry) SnapshotTenant(tenant string, now time.Time, staleAfter time.Duration) RegistrySnapshot
- func (r *Registry) Upsert(heartbeat Heartbeat) HeartbeatDisposition
- type RegistrySnapshot
- type State
- type WorkerSnapshot
Constants ¶
const ( // MaxIdentityBytes bounds worker status labels. MaxIdentityBytes = 256 // MaxQueuesPerWorker bounds one heartbeat's queue cardinality. MaxQueuesPerWorker = 256 // MaxCapabilitiesPerWorker bounds negotiated capability cardinality. MaxCapabilitiesPerWorker = 64 // MaxWorkerConcurrency bounds reported goroutine concurrency. MaxWorkerConcurrency = 1_000_000 )
Variables ¶
var ErrInvalidTelemetryConfiguration = errors.New("fleet: invalid telemetry configuration")
ErrInvalidTelemetryConfiguration reports unusable fleet metric settings.
Functions ¶
This section is empty.
Types ¶
type Capability ¶
type Capability string
Capability identifies one negotiated data-plane management operation.
const ( CapabilityWorkerStatus Capability = "worker_status" CapabilityQueueStatus Capability = "queue_status" CapabilityPause Capability = "pause" CapabilityResume Capability = "resume" CapabilityDrain Capability = "drain" CapabilityTerminate Capability = "terminate" CapabilityFailures Capability = "failures" CapabilityDeadLetters Capability = "dead_letters" CapabilityRetry Capability = "retry" CapabilityBulkRetry Capability = "bulk_retry" CapabilityDelete Capability = "delete" CapabilityPurge Capability = "purge" CapabilityReplay Capability = "replay" CapabilityRetentionCount Capability = "retention_count" CapabilityRetentionTime Capability = "retention_time" CapabilityRetentionBytes Capability = "retention_bytes" )
type Compatibility ¶
type Compatibility struct {
State CompatibilityState `json:"state"`
Enabled []Capability `json:"enabled"`
WorkerOnly []Capability `json:"worker_only"`
ControlPlaneOnly []Capability `json:"control_plane_only"`
}
Compatibility is the deterministic result of protocol and capability negotiation.
func Negotiate ¶
func Negotiate( supported ProtocolRange, worker ProtocolVersion, workerCapabilities []Capability, controlPlaneCapabilities []Capability, ) Compatibility
Negotiate safely compares a worker report with the control-plane range and enables only capabilities both sides support at a compatible version.
type CompatibilityState ¶
type CompatibilityState string
CompatibilityState describes a worker relative to the supported protocol range without pretending an incompatible worker is controllable.
const ( CompatibilityCompatible CompatibilityState = "compatible" CompatibilityWorkerOlder CompatibilityState = "worker_older" CompatibilityWorkerNewer CompatibilityState = "worker_newer" CompatibilityUnknown CompatibilityState = "unknown" )
type DrainState ¶
type DrainState string
DrainState describes progress of a graceful drain request.
const ( DrainNotRequested DrainState = "not_requested" DrainRequested DrainState = "requested" DrainInProgress DrainState = "in_progress" DrainCompleted DrainState = "completed" DrainTimedOut DrainState = "timed_out" )
type Heartbeat ¶
type Heartbeat struct {
TenantID string
WorkerID string
Version string
StartedAt time.Time
ObservedAt time.Time
Queues []string
Concurrency uint32
State State
CurrentJobs uint32
DrainStatus DrainState
Backend string
Protocol ProtocolVersion
Capabilities []Capability
}
Heartbeat is the latest status reported by a worker.
func (Heartbeat) EffectiveState ¶
EffectiveState safely classifies a heartbeat at the supplied observation time. Missing, future, and malformed reports are never treated as healthy.
type HeartbeatDisposition ¶
type HeartbeatDisposition string
HeartbeatDisposition describes how the registry handled one report.
const ( HeartbeatAccepted HeartbeatDisposition = "accepted" HeartbeatDuplicate HeartbeatDisposition = "duplicate" HeartbeatReordered HeartbeatDisposition = "reordered" HeartbeatConflict HeartbeatDisposition = "conflict" HeartbeatInvalid HeartbeatDisposition = "invalid" HeartbeatCapacityExceeded HeartbeatDisposition = "capacity_exceeded" )
type HeartbeatValidationError ¶
HeartbeatValidationError identifies one invalid worker-status field.
func (*HeartbeatValidationError) Error ¶
func (e *HeartbeatValidationError) Error() string
type Projection ¶
type Projection struct {
// contains filtered or unexported fields
}
Projection consumes queue lifecycle events without accessing a backend. New queue identities beyond the configured limit are aggregated into the overflow bucket to keep memory use bounded.
func NewProjection ¶
func NewProjection(maxQueues int) *Projection
NewProjection creates a projection that retains at most maxQueues distinct queue identities. Non-positive limits retain no identities and aggregate all events into the overflow bucket.
func (*Projection) Observe ¶
func (p *Projection) Observe(event queue.Event)
Observe implements queue.Observer.
func (*Projection) Snapshot ¶
func (p *Projection) Snapshot() ProjectionSnapshot
Snapshot returns a deterministic copy safe for concurrent readers.
type ProjectionSnapshot ¶
type ProjectionSnapshot struct {
Queues []QueueSnapshot
Overflow QueueMetrics
}
ProjectionSnapshot is an immutable point-in-time fleet projection.
type ProtocolRange ¶
type ProtocolRange struct {
Minimum ProtocolVersion
Maximum ProtocolVersion
}
ProtocolRange is the inclusive protocol range supported by the control plane during rolling upgrades.
type ProtocolVersion ¶
ProtocolVersion identifies a worker/control-plane management protocol.
type QueueMetrics ¶
QueueMetrics is a bounded current-state projection of lifecycle events. Runtime is cumulative so a metrics backend can derive honest averages and rates without this package retaining an unbounded time series.
type QueueSnapshot ¶
type QueueSnapshot struct {
Backend string
Queue string
Metrics QueueMetrics
}
QueueSnapshot identifies one queue's current projected counters.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry retains a bounded set of latest worker heartbeats.
func NewRegistry ¶
NewRegistry creates a registry that retains at most maxWorkers identities.
func (*Registry) RegisterTelemetry ¶
func (r *Registry) RegisterTelemetry( meter metric.Meter, now func() time.Time, staleAfter time.Duration, ) (metric.Registration, error)
RegisterTelemetry exports fixed-cardinality fleet state and rejection measurements. The caller owns the returned registration lifecycle.
func (*Registry) SnapshotTenant ¶
func (r *Registry) SnapshotTenant( tenant string, now time.Time, staleAfter time.Duration, ) RegistrySnapshot
SnapshotTenant returns only one tenant's workers and rejection count.
func (*Registry) Upsert ¶
func (r *Registry) Upsert(heartbeat Heartbeat) HeartbeatDisposition
Upsert ingests one heartbeat without allowing delayed, duplicate, or conflicting reports to falsely advance worker state.
type RegistrySnapshot ¶
type RegistrySnapshot struct {
Workers []WorkerSnapshot
Rejected uint64
}
RegistrySnapshot is a deterministic point-in-time view of retained workers.
type WorkerSnapshot ¶
WorkerSnapshot contains a defensively copied heartbeat and its derived fail-safe state.