Documentation ¶
Index ¶
Constants ¶
const ( ExitOK = iota ExitPanic ExitEngine )
Returned values on exit
Variables ¶
This section is empty.
Functions ¶
Types ¶
type DefaultEngine ¶
type DefaultEngine struct {
// contains filtered or unexported fields
}
DefaultEngine is the default Engine implementation
func NewDefaultEngine ¶
func NewDefaultEngine() *DefaultEngine
NewDefaultEngine creates an engine that handles SIGINT and SIGTERM as stop signals. It only implements engine.Main.
func (*DefaultEngine) AskStop ¶
func (e *DefaultEngine) AskStop(state int)
AskStop unlock engine.Start() wait on StopSignal() and set the engine to be stopped.
func (*DefaultEngine) Initialize ¶
func (e *DefaultEngine) Initialize() error
Initialize setup SIGINT, SIGTERM and SIGKILL catch and must be called by other Initialize() functions. Any error != nil returned will prevent the engine to be started.
func (*DefaultEngine) ProcessStopped ¶
func (e *DefaultEngine) ProcessStopped()
ProcessStopped must not be called more than once per process that has effectively stopped.
func (*DefaultEngine) StopSignal ¶
func (e *DefaultEngine) StopSignal() <-chan os.Signal
StopSignal returns the channel where signals are captured to handle graceful stop.
func (*DefaultEngine) WaitStopped ¶
func (e *DefaultEngine) WaitStopped()
WaitStopped awaits all processes to finish.
type DefaultPartialPeriodical ¶
type DefaultPartialPeriodical struct {
// contains filtered or unexported fields
}
DefaultPartialPeriodical implements basic functions and lets you implement the actual periodical process function.
func (*DefaultPartialPeriodical) PeriodicalContinue ¶
func (e *DefaultPartialPeriodical) PeriodicalContinue() bool
PeriodicalContinue returns the internal engine continue state
func (*DefaultPartialPeriodical) PeriodicalRecover ¶
func (e *DefaultPartialPeriodical) PeriodicalRecover()
PeriodicalRecover a panic from the Periodical Process and ask the engine to stop
func (*DefaultPartialPeriodical) PeriodicalStopped ¶
func (e *DefaultPartialPeriodical) PeriodicalStopped()
PeriodicalStopped acknowledge the periodical process stop
func (*DefaultPartialPeriodical) PeriodicalWait ¶
func (e *DefaultPartialPeriodical) PeriodicalWait() time.Duration
PeriodicalWait returns 60s by default
type DefaultPartialWorker ¶
type DefaultPartialWorker struct {
// contains filtered or unexported fields
}
DefaultPartialWorker lets you implement the actual Worker Process
func (*DefaultPartialWorker) WorkerContinue ¶
func (e *DefaultPartialWorker) WorkerContinue() bool
WorkerContinue returns the internal continue state
func (*DefaultPartialWorker) WorkerRecover ¶
func (e *DefaultPartialWorker) WorkerRecover()
WorkerRecover a panic from Worker Process and asks the engine to stop
func (*DefaultPartialWorker) WorkerStopped ¶
func (e *DefaultPartialWorker) WorkerStopped()
WorkerStopped acknowledge Worker Process stopped
type FullEngine ¶
type FullEngine struct { Main Worker Periodical }
FullEngine is a Worker + Periodical engine
type Main ¶
type Main interface { Initialize() error Continue() bool // AskStop must change Continue() return value to false // and StopSignal() to deliver a value through the channel. AskStop(int) StopSignal() <-chan os.Signal // ProcessStopped must be called by each process when they are // actually stopped, or have recovered from a panic. ProcessStopped() WaitStopped() }
Main ...
type PartialPeriodical ¶
type PartialPeriodical interface { PeriodicalContinue() bool PeriodicalWait() time.Duration PeriodicalStopped() PeriodicalRecover() }
PartialPeriodical implements most basic engine functions
func NewPartialPeriodical ¶
func NewPartialPeriodical(m Main) PartialPeriodical
NewPartialPeriodical ...
type PartialWorker ¶
type PartialWorker interface { WorkerContinue() bool WorkerStopped() WorkerRecover() }
PartialWorker implements basic engine functions
type Periodical ¶
type Periodical interface { PartialPeriodical PeriodicalProcess() error }
Periodical ...