runner

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrGroup

type ErrGroup struct {
	Errs []error
}

func (ErrGroup) Error

func (e ErrGroup) Error() string

type Group

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

func NewGroup

func NewGroup(shutdownTimeout time.Duration) *Group

func (*Group) Errors

func (g *Group) Errors() error

func (*Group) Register

func (g *Group) Register(fn RunFunc, shutdownFn ShutdownFunc) *Group

func (*Group) Shutdown

func (g *Group) Shutdown() error

Shutdown runs shutdown handlers provided by each runner during registration, and exits if the shutdown timeout reached or all of the shutdown handler return. It returns non-nil error if one of the shutdown handlers returns error, or if the timeout is reached. The returned error type is ErrGroup (if it is non-nil).

func (*Group) Wait

func (g *Group) Wait(ctx context.Context) *Group

Wait starts runners and returns if

  1. The process receives SIGTERM or SIGINT.
  2. One of the runner returns with non-nil error.
  3. The input context is done.

When this function returns, the process no longer masks signal handling.

type RunFunc

type RunFunc func() error

type ShutdownFunc

type ShutdownFunc func(context.Context) error

Jump to

Keyboard shortcuts

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