Documentation
¶
Index ¶
- type ISupervisor
- type Supervisor
- type SupervisorOption
- func WithHaltingErrors(errs ...error) SupervisorOption
- func WithPostStart(function func(context.Context) error) SupervisorOption
- func WithPostStop(function func(context.Context, error) error) SupervisorOption
- func WithPreStart(function func(context.Context) error) SupervisorOption
- func WithRestartDelay(delay time.Duration) SupervisorOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ISupervisor ¶
type ISupervisor interface { // Run will run the supervisor and execute any of the command hooks. If it receives a halting error or the context is cancelled then it will exit Run(ctx context.Context) error }
ISupervisor will run a command and automatically restart it if it exits. Hooks can be used to execute code at different points in the execution lifecyle. Restarts can be delayed
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
A Supervisor will run a command and automatically restart it if it exits. Hooks can be used to execute code at different points in the execution lifecyle. Restarts can be delayed
func NewSupervisor ¶
func NewSupervisor(newCommand func(ctx context.Context) (*subprocess.Subprocess, error), opts ...SupervisorOption) *Supervisor
NewSupervisor will take a function 'newCommand' that creates a command and run it every time the command exits. Options can be supplied by the 'opts' variadic argument that control the lifecyle of the supervisor
type SupervisorOption ¶
type SupervisorOption func(*Supervisor)
func WithHaltingErrors ¶
func WithHaltingErrors(errs ...error) SupervisorOption
WithHaltingErrors are errors that won't trigger the supervisor to restart and on which, the subprocess will just halt.
func WithPostStart ¶
func WithPostStart(function func(context.Context) error) SupervisorOption
WithPostStart will run 'function' after the supervisor has started
func WithPostStop ¶
func WithPostStop(function func(context.Context, error) error) SupervisorOption
WithPostStop will run 'function' after the supervised command has stopped It's context will ignore cancellations so any timeouts should be added within the function body itself
func WithPreStart ¶
func WithPreStart(function func(context.Context) error) SupervisorOption
WithPreStart will run 'function' before the supervisor starts
func WithRestartDelay ¶
func WithRestartDelay(delay time.Duration) SupervisorOption
WithRestartDelay will delay the supervisor from restarting for a period of time specified by 'delay'