Documentation ¶
Index ¶
Constants ¶
View Source
const ( StateEmpty = "empty" StateStarted = "started" StateStopped = "stopped" )
Valid state values
Variables ¶
View Source
var ( ErrStartInvalid = errors.New("Attempting to start a service that has already been started") ErrStopInvalid = errors.New("Attempting to stop a service that is not running") ErrWaitInvalid = errors.New("Attempting to wait on a service that is not running") )
errors
Functions ¶
func StartAndWait ¶
StartAndWait is helper for the initialization Start & Wait pattern
Types ¶
type LifecycleFn ¶
LifecycleFn is a helper type for describing the start, stop, wait methods
func LifecycleFnNoCtx ¶
func LifecycleFnNoCtx(fn func() error) LifecycleFn
LifecycleFnNoCtx is a helper that turns a func() error into a LifecycleFn
type Service ¶
type Service interface { Start(context.Context) error Stop(context.Context) error Wait(context.Context) error }
A Service is a long running process that can start, stop and wait.
func FromBlocking ¶
func FromBlocking(start LifecycleFn, stop LifecycleFn) Service
FromBlocking transforms a blocking start func (like http.ListenAndServe) and returns a Service
func FromStartStop ¶
func FromStartStop(start LifecycleFn, stop LifecycleFn) Service
FromStartStop wraps a start function that returns immediately and returns a Service
Click to show internal directories.
Click to hide internal directories.