supervisor

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartDefaultLink(self erl.PID, children []ChildSpec, supFlags SupFlagsS, optFuns ...LinkOpts) (erl.PID, error)

Instead of defining a callback module, just pass a list of children.

func StartLink(self erl.PID, callback Supervisor, args any, optFuns ...LinkOpts) (erl.PID, error)

Types

type ChildSpec

type ChildSpec struct {
	// used to identify the child process internally by the Supervisor
	ID string
	// error's of type exitreason.S are special, such as [exitreason.Ignore]. The function must link the process
	// to the supervisor
	Start    StartFunSpec
	Restart  Restart
	Shutdown ShutdownOpt
	Type     ChildType
	// contains filtered or unexported fields
}

func NewChildSpec

func NewChildSpec(id string, start StartFunSpec, opts ...ChildSpecOpt) ChildSpec

func NewTestServerChildSpec added in v0.7.0

func NewTestServerChildSpec[STATE any](id string, ts genserver.TestServer[STATE], gsOpts genserver.StartOpts, opts ...ChildSpecOpt) ChildSpec

type ChildSpecOpt

type ChildSpecOpt func(cs ChildSpec) ChildSpec

func SetChildType

func SetChildType(t ChildType) ChildSpecOpt

func SetRestart

func SetRestart(restart Restart) ChildSpecOpt

func SetShutdown

func SetShutdown(shutdown ShutdownOpt) ChildSpecOpt

type ChildType

type ChildType string
const (
	SupervisorChild ChildType = "supervisor"
	WorkerChild     ChildType = "worker"
)

type InitResult

type InitResult struct {
	SupFlags   SupFlagsS
	ChildSpecs []ChildSpec
	Ignore     bool
}

type LinkOpts

type LinkOpts func(flags linkOpts) linkOpts

func SetName

func SetName(name erl.Name) LinkOpts

type Restart

type Restart string

child_spec

const (
	Permanent Restart = "permanent"
	Temporary Restart = "temporary"
	Transient Restart = "transient"
)

type ShutdownOpt

type ShutdownOpt struct {
	BrutalKill bool
	Timeout    int
	Infinity   bool
}

child_spec

type StartFunSpec

type StartFunSpec func(sup erl.PID) (erl.PID, error)

type Strategy

type Strategy string

sup flag

const (
	OneForOne  Strategy = "one_for_one"
	OneForAll  Strategy = "one_for_all"
	RestForOne Strategy = "rest_for_one"
)

type SupFlag

type SupFlag func(flags SupFlagsS) SupFlagsS

func SetIntensity

func SetIntensity(intensity int) SupFlag

func SetPeriod

func SetPeriod(period int) SupFlag

func SetStrategy

func SetStrategy(strategy Strategy) SupFlag

type SupFlagsS

type SupFlagsS struct {
	Strategy Strategy
	// duration of the evaluation window for restarts, in seconds
	Period int
	// how many restarts allowed within [Period]
	Intensity int
}

func NewSupFlags

func NewSupFlags(flags ...SupFlag) SupFlagsS

type Supervisor

type Supervisor interface {
	Init(self erl.PID, args any) InitResult
}

type SupervisorS

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

Impelements genserver.GenServer and accepts the callback module for Supervisor

func (SupervisorS) HandleCall

func (s SupervisorS) HandleCall(self erl.PID, request any, from genserver.From, state supervisorState) (genserver.CallResult[supervisorState], error)

func (SupervisorS) HandleCast

func (s SupervisorS) HandleCast(self erl.PID, arg any, state supervisorState) (genserver.CastResult[supervisorState], error)

func (SupervisorS) HandleContinue

func (s SupervisorS) HandleContinue(self erl.PID, continuation any, state supervisorState) (supervisorState, any, error)

func (SupervisorS) HandleInfo

func (s SupervisorS) HandleInfo(self erl.PID, request any, state supervisorState) (genserver.InfoResult[supervisorState], error)

func (SupervisorS) Init

func (s SupervisorS) Init(self erl.PID, args any) (genserver.InitResult[supervisorState], error)

func (SupervisorS) Terminate

func (s SupervisorS) Terminate(self erl.PID, arg error, state supervisorState)

Jump to

Keyboard shortcuts

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