supervisor

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RestartStrategy

type RestartStrategy int
const (
	// PermanentRestartStrategy the child process is always restarted.
	PermanentRestartStrategy RestartStrategy = iota
	// TemporaryRestartStrategy the child process is never restarted, regardless of the supervision strategy.
	// Any termination (even abnormal) is considered successful.
	TemporaryRestartStrategy
	// TransientRestartStrategy child process is restarted only if it terminates abnormally
	TransientRestartStrategy
)

type ShutdownStrategy

type ShutdownStrategy int
const (
	ImmediateShutdownStrategy ShutdownStrategy = iota
	TimeoutShutdownStrategy
)

type Spec

type Spec struct {
	Strategy Strategy
	Manifest async.Manifest
	Args     any
}

func NewSpec

func NewSpec(manifest async.Manifest, args any, opts ...StrategyOption) Spec

type State

type State struct {
	Retries   int
	LastError error
}

type Strategy

type Strategy struct {
	Restart     RestartStrategy
	Shutdown    ShutdownStrategy
	Supervision SupervisionStrategy
}

func NewStrategy

func NewStrategy() Strategy

type StrategyOption

type StrategyOption func(strategy *Strategy)

func WithRestartStrategy

func WithRestartStrategy(restart RestartStrategy) StrategyOption

func WithShutdownStrategy

func WithShutdownStrategy(shutdown ShutdownStrategy) StrategyOption

func WithSupervisionStrategy

func WithSupervisionStrategy(supervision SupervisionStrategy) StrategyOption

type SupervisionStrategy

type SupervisionStrategy int
const (
	// OneForOneSupervisionStrategy if a child process terminates, only that process is restarted.
	OneForOneSupervisionStrategy SupervisionStrategy = iota
	// OneForAllSupervisionStrategy  if a child process terminates, all other child processes are terminated and then
	// all child processes (including the terminated one) are restarted.
	OneForAllSupervisionStrategy
)

type Supervisor

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

func New

func New(name string, children ...Spec) *Supervisor

func (*Supervisor) Manifest

func (s *Supervisor) Manifest() async.Manifest

Jump to

Keyboard shortcuts

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