supervisor

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package supervisor provides the restart policy configuration surface for plugin process supervision. A host supplies a RestartPolicy to control how crashed plugins are restarted.

Index

Constants

This section is empty.

Variables

View Source
var NoRestart = RestartPolicy{}

NoRestart is a RestartPolicy under which styx never restarts a crashed plugin on its own. Use it when the embedding process already owns restart decisions (its own supervisor, an orchestrator, a process manager) and would otherwise race styx's own restart loop.

After the first crash, the supervisor emits EventCrashed and then exactly one EventGaveUp for that instance, unless the supervisor or its owning Host is stopped in the gap between the two — a host that is itself stopping has no use for a give-up signal, so the give-up may not be published at all in that case. EventRestarting is never published, the process is never respawned, and more than one EventGaveUp can never occur. Per-call errors up to that point still follow the normal crash taxonomy (PluginCrashError and friends) — NoRestart changes only whether a new process is spawned, not how a crash already in flight is reported.

NoRestart is the RestartPolicy zero value, so a caller who never sets Config.Restart already gets this behavior; naming it makes the choice explicit and documents the contract rather than relying on an inferred zero value.

Functions

This section is empty.

Types

type BackoffFunc

type BackoffFunc func(attempt int) time.Duration

BackoffFunc computes the delay before a restart attempt. Attempt is 0-indexed: attempt 0 is the delay before the first restart, after the initial crash.

func ExpBackoff

func ExpBackoff(base, maxDelay time.Duration) BackoffFunc

ExpBackoff returns a BackoffFunc computing exponential backoff: base*2^attempt, capped at maxDelay, with up to 20% jitter added. The jitter reduces the likelihood that multiple plugin instances restart simultaneously at the same wall-clock time.

type RestartPolicy

type RestartPolicy struct {
	Max     int
	Backoff BackoffFunc
}

RestartPolicy controls how many times a plugin is restarted after a crash and how long to wait between restart attempts. A RestartPolicy is safe for concurrent use.

Jump to

Keyboard shortcuts

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