supervisor

package
v2.0.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2025 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const ServiceTimeout = 10 * time.Second

Variables

This section is empty.

Functions

func IsFatal

func IsFatal(err error) bool

func NoRestartErr

func NoRestartErr(err error) error

NoRestartErr wraps the given error err (which may be nil) to make sure that `errors.Is(err, suture.ErrDoNotRestart) == true`.

func SpecWithDebugLogger

func SpecWithDebugLogger() suture.Spec

func SpecWithInfoLogger

func SpecWithInfoLogger() suture.Spec

Types

type ExitStatus

type ExitStatus int
const (
	ExitSuccess            ExitStatus = 0
	ExitError              ExitStatus = 1
	ExitNoUpgradeAvailable ExitStatus = 2
	ExitRestart            ExitStatus = 3
	ExitUpgrade            ExitStatus = 4
)

func (ExitStatus) AsInt

func (s ExitStatus) AsInt() int

type FatalErr

type FatalErr struct {
	Err    error
	Status ExitStatus
}

func AsFatalErr

func AsFatalErr(err error, status ExitStatus) (gErr *FatalErr)

AsFatalErr wraps the given error creating a FatalErr. If the given error already is of type FatalErr, it is not wrapped again.

func (*FatalErr) Error

func (e *FatalErr) Error() string

func (*FatalErr) Is

func (*FatalErr) Is(target error) bool

func (*FatalErr) Unwrap

func (e *FatalErr) Unwrap() error

type Manager

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

func Default

func Default(lc lifecycle.Getter) *Manager

func NewManager

func NewManager(name string, lc lifecycle.Getter) *Manager

func (*Manager) Add

func (m *Manager) Add(srv Service) error

func (*Manager) Delete

func (m *Manager) Delete(name string) error

func (*Manager) Has

func (m *Manager) Has(name string) bool

func (*Manager) OnClose

func (m *Manager) OnClose(fn func())

func (*Manager) RemoveServices

func (m *Manager) RemoveServices() (gErr error)

func (*Manager) RestartService

func (m *Manager) RestartService(name string) (gErr error)

func (*Manager) RestartServices

func (m *Manager) RestartServices() (gErr error)

func (*Manager) Run

func (m *Manager) Run(ctx context.Context) error

func (*Manager) Serve

func (m *Manager) Serve(ctx context.Context) error

func (*Manager) ServeBackground

func (m *Manager) ServeBackground(ctx context.Context) <-chan error

func (*Manager) Services

func (m *Manager) Services() []Service

type Metric

type Metric struct {
	Name           string
	Error          string
	Restart        uint32
	StartTime      time.Time
	OnlineDuration time.Duration
}

type Service

type Service interface {
	Name() string
	Error() error
	String() string
	Serve(ctx context.Context) error
	Metric() *Metric
}

func NewService

func NewService(name string, fn func(ctx context.Context) error) Service

type Supervisor

type Supervisor = suture.Supervisor

Jump to

Keyboard shortcuts

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