v0.0.0-...-4be1d82 Latest Latest

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 15 Imported by: 6




This section is empty.


View Source
var (
	// ErrCanOnlyRunOnce is returned when `RunAndWait` is called after already
	// being called.
	ErrCanOnlyRunOnce = errors.New("can only run once")

	// ErrShutdownRequested can be used as a reason for `Kill` that indicates no
	// error has occurred, just that the components should gracefully exit.
	ErrShutdownRequested = errors.New("shutdown requested")


This section is empty.


type Component

type Component interface {

Component is used to represent various "components". At a high level, main() essentially cobbles together a few components whose lifecycles are managed by Tombs. `Component` allows us to treat them as black boxes.

type ComponentWithDependencies

type ComponentWithDependencies interface {

	Dependencies() []Component

func NewComponentWithDependencies

func NewComponentWithDependencies(c Component, dependencies ...Component) ComponentWithDependencies

type Main

type Main struct {
	// contains filtered or unexported fields

Main represents a collection of components whose lifecycles are tied together.

func New

func New(components ...Component) Main

New creates a new `Main`

func (*Main) Kill

func (m *Main) Kill(reason error)

Kill will terminate all running components with a given reason

func (*Main) RunAndWait

func (m *Main) RunAndWait() error

RunAndWait starts all components in this `Main`.

`RunAndWait` will also listen to SIGINT and SIGTERM to do graceful shutdowns of all components it manages. It should only be called once, and returns `ErrCanOnlyRunOnce` if called more than once.

func (*Main) SetShutdownDeadline

func (m *Main) SetShutdownDeadline(d time.Duration)

type SignalError

type SignalError struct {
	// contains filtered or unexported fields

SignalError is an `error` returned when `Main` exits due to a signal.

func (*SignalError) Error

func (s *SignalError) Error() string

Jump to

Keyboard shortcuts

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