Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*options)
Option configures supervisor worker behavior.
func WithBackoff ¶
WithBackoff sets the initial backoff between restarts.
func WithMaxBackoff ¶
WithMaxBackoff caps the backoff between restarts.
func WithMaxRestarts ¶
WithMaxRestarts limits the number of restarts (0 = unlimited).
func WithRestartPolicy ¶
func WithRestartPolicy(policy RestartPolicy) Option
WithRestartPolicy sets the restart policy.
type RestartPolicy ¶
type RestartPolicy int
RestartPolicy controls when a worker should be restarted.
const ( RestartNever RestartPolicy = iota RestartOnError RestartAlways )
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor manages worker lifecycles with restart policies.
func New ¶
func New(parent context.Context) *Supervisor
New creates a supervisor bound to the parent context.
func (*Supervisor) Context ¶
func (s *Supervisor) Context() context.Context
Context returns the supervisor context.
func (*Supervisor) SetErrorHandler ¶
func (s *Supervisor) SetErrorHandler(handler func(name string, err error))
SetErrorHandler registers a handler for worker errors.
func (*Supervisor) Stop ¶
func (s *Supervisor) Stop()
Stop cancels all workers and waits for them to exit.
Click to show internal directories.
Click to hide internal directories.