Documentation ¶
Overview ¶
Package routines provides utilities for managing long-running goroutines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type InitRoutine ¶
type InitRoutine interface { Routine // Init is an initialization function that is called before any routines // are run, including this one. Routines must not depend on eachother in // this function. Init(context.Context) error }
InitRoutine is a routine that has to be initialized before it can be run.
type Manager ¶
type Manager struct { // Routines specifies a list of routines to manage. These are started // when Run() is called. Routines []Routine // RestartDeadline specifies the amount of time a routine has to be // running before failing to be restarted. This is to prevent routines // that immediately fail from just being restarted over and over again. // Defaults to 32 seconds if not set. RestartDeadline time.Duration // Logger, if non-nil, is where log messages will be written to. If it // is nil, messages will be written to the standard logger. To disable // logging altogether, this can be set to io.Discard. Logger io.Writer // contains filtered or unexported fields }
Manager is a system capable of managing multiple routines, and restarting them if they fail.
type Routine ¶
type Routine interface { // Run is a long-running function that does not return until it is // finished, or its context is cancelled. If the context is cancelled, // the function must perform necessary cleanup/shutdown operations and // exit. An error is returned if the routine exited due to an error. Run(context.Context) error }
Routine is an object that can be run and stopped.
Click to show internal directories.
Click to hide internal directories.