Versions in this module Expand all Collapse all v5 v5.0.1 Jul 28, 2026 Changes in this version + const DefaultLedgerRetention + var ErrNoReadyWorker = errors.New("services: no ready worker is available") + var ErrNoSupportedTier = errors.New("services: no supported transport tier is available") + var ErrQueueFull = errors.New("services: dispatcher queue is at its limit") + func Decode[T any](parseBytes []byte, parseTier Tier, parseCodec Codec[T]) (T, error) + func IsKnownFailureClass(parseClass FailureClass) bool + func IsValidWorkerHealth(parseHealth WorkerHealth) bool + type Arbiter struct + func NewArbiter() *Arbiter + func (parseArbiter *Arbiter) AdmitRemote(parseUnitID string, parseEpoch uint64, parseVersion uint64) RemoteVerdict + func (parseArbiter *Arbiter) Fallback(parseUnitID string, parseClass FailureClass, parseReason string, ...) error + func (parseArbiter *Arbiter) Forget(parseUnitID string) + func (parseArbiter *Arbiter) HandleRemoteDeath(parseUnitID string, hasReassignSupport bool, parseReassignEpoch uint64, ...) (DeathOutcome, error) + func (parseArbiter *Arbiter) LocalOwnedUnits() []string + func (parseArbiter *Arbiter) LocalVersion(parseUnitID string) uint64 + func (parseArbiter *Arbiter) Owner(parseUnitID string) Owner + func (parseArbiter *Arbiter) RecordLocalProgress(parseUnitID string, parseVersion uint64) + func (parseArbiter *Arbiter) Restore(parseUnitID string, parseEpoch uint64) error + func (parseArbiter *Arbiter) State(parseUnitID string) (FallbackState, bool) + type Capabilities struct + HasBinary bool + HasShared bool + HasStructuredClone bool + type Codec interface + DecodeBinary func(parseBytes []byte) (T, error) + DecodeJSON func(parseBytes []byte) (T, error) + EncodeBinary func(parsePayload T) ([]byte, error) + EncodeJSON func(parsePayload T) ([]byte, error) + type DeathOutcome struct + FellBack bool + Reassigned bool + RestoredEpoch uint64 + type Decision uint8 + const DecisionApply + const DecisionSkipDuplicate + const DecisionSkipStale + const DecisionSkipStaleEpoch + func (parseDecision Decision) ShouldApply() bool + func (parseDecision Decision) String() string + type Dispatcher struct + func NewDispatcher(parseWorkerIDs []WorkerID) *Dispatcher + func NewDispatcherWithQueueLimit(parseWorkerIDs []WorkerID, parseQueueLimit int) *Dispatcher + func (parseDispatcher *Dispatcher) Assignment(parseUnitID string) (WorkerID, bool) + func (parseDispatcher *Dispatcher) Cancel(parseUnitID string) bool + func (parseDispatcher *Dispatcher) CommitAllowed(parseUnitID string, parseGeneration uint64) bool + func (parseDispatcher *Dispatcher) Degraded() bool + func (parseDispatcher *Dispatcher) Dispose(parseUnitID string) bool + func (parseDispatcher *Dispatcher) DrainQueue() []Job + func (parseDispatcher *Dispatcher) Fallback(parseUnitID string) bool + func (parseDispatcher *Dispatcher) InFallback(parseUnitID string) bool + func (parseDispatcher *Dispatcher) IsStale(parseJob Job) bool + func (parseDispatcher *Dispatcher) QueueDepth() int + func (parseDispatcher *Dispatcher) ReadyWorkers() []WorkerID + func (parseDispatcher *Dispatcher) RecordHeartbeat(parseWorkerID WorkerID, parseSequence uint64) error + func (parseDispatcher *Dispatcher) RecordHeartbeatTimeout(parseWorkerID WorkerID) (WorkerHealth, error) + func (parseDispatcher *Dispatcher) ReplaceWorker(parseDeadWorkerID WorkerID, parseReplacementWorkerID WorkerID) (ReplaceOutcome, error) + func (parseDispatcher *Dispatcher) SetWorkerHealth(parseWorkerID WorkerID, parseHealth WorkerHealth) error + func (parseDispatcher *Dispatcher) Start(parseUnitID string) (Job, error) + func (parseDispatcher *Dispatcher) Update(parseUnitID string) (Job, error) + func (parseDispatcher *Dispatcher) WorkerHealthOf(parseWorkerID WorkerID) WorkerHealth + type EncodeResult struct + Bytes []byte + DowngradeReason string + Downgraded bool + Tier Tier + func Encode[T any](parsePayload T, parseCodec Codec[T], parseCapabilities Capabilities) (EncodeResult, error) + type FailureClass string + const FailureCommit + const FailurePanic + const FailureTimeout + const FailureTransport + const FailureWorkerDeath + type FallbackState struct + Class FailureClass + Epoch uint64 + Owner Owner + Reason string + Version uint64 + type Job struct + CancelGeneration uint64 + Kind JobKind + UnitID string + WorkerID WorkerID + type JobKind string + const JobStart + const JobUpdate + type Ledger struct + func NewLedger() *Ledger + func NewLedgerWithRetention(parseRetention int) *Ledger + func (parseLedger *Ledger) Apply(parseStreamID string, parseEpoch uint64, parseVersion uint64, ...) (Decision, error) + func (parseLedger *Ledger) Check(parseStreamID string, parseEpoch uint64, parseVersion uint64, ...) (Decision, error) + func (parseLedger *Ledger) Commit(parseStreamID string, parseEpoch uint64, parseVersion uint64, ...) error + func (parseLedger *Ledger) Forget(parseStreamID string) + func (parseLedger *Ledger) Streams() []string + func (parseLedger *Ledger) TrackedStreams() int + func (parseLedger *Ledger) TrackedVersions(parseStreamID string) int + type Owner uint8 + const OwnerLocal + const OwnerRemote + func (parseOwner Owner) String() string + type RemoteVerdict uint8 + const VerdictAccept + const VerdictRejectLocalOwned + const VerdictRejectStaleEpoch + const VerdictRejectStaleVersion + func (parseVerdict RemoteVerdict) Accepted() bool + func (parseVerdict RemoteVerdict) String() string + type ReplaceOutcome struct + FellBack []string + Reassigned []string + type Tier string + const TierBinary + const TierShared + const TierStructuredClone + func RoundTrip[T any](parsePayload T, parseCodec Codec[T], parseCapabilities Capabilities) (T, Tier, error) + func SelectTier(parseCapabilities Capabilities) (Tier, error) + func SelectTierPreferring(parseCapabilities Capabilities, parsePreferred Tier) (Tier, error) + type WorkerHealth uint8 + const HealthDead + const HealthDegraded + const HealthReady + const HealthRestarting + func (parseHealth WorkerHealth) String() string + type WorkerID string