Documentation ¶
Index ¶
- type Callback
- type Config
- type Finalizer
- type Guillotine
- func (g *Guillotine) AddCloser(closer io.Closer, cb ...Callback)
- func (g *Guillotine) AddFinalizer(f Finalizer, cb ...Callback)
- func (g *Guillotine) AddFunc(f func(), cb ...Callback)
- func (g *Guillotine) Execute() (ok bool, errs []error)
- func (g *Guillotine) Trigger()
- func (g *Guillotine) TriggerOnSignal(sig ...os.Signal)
- func (g *Guillotine) TriggerOnTerminate()
- func (g *Guillotine) Wait() []error
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Callback ¶
A Callback is called when a Guillotine runs a Finalizer.
It is used as a way to perform other actions after a Finalizer is run, and to modify the error returned by the Finalizer.
func WithEffect ¶ added in v0.1.1
WithEffect creates a Callback that runs a function that receives the error created by the Finalizer, and returns nothing.
It is intended for functions with side effects involving the error, like logging functions, etc.
func WithError ¶
WithError creates a Callback that creates an Error if the Finalizer didn't return one.
func WithErrorf ¶
WithErrorf is like WithError, but creates a formatted error message.
type Guillotine ¶
type Guillotine struct {
// contains filtered or unexported fields
}
A Guillotine is used to shut down a system consisting of multiple components.
func (*Guillotine) AddCloser ¶
func (g *Guillotine) AddCloser(closer io.Closer, cb ...Callback)
AddCloser adds an io.Closer to the Guillotine.
func (*Guillotine) AddFinalizer ¶
func (g *Guillotine) AddFinalizer(f Finalizer, cb ...Callback)
AddFinalizer adds a Finalizer to the Guillotine.
func (*Guillotine) AddFunc ¶
func (g *Guillotine) AddFunc(f func(), cb ...Callback)
AddFunc adds a regular function to the Guillotine.
func (*Guillotine) Execute ¶
func (g *Guillotine) Execute() (ok bool, errs []error)
Execute runs each Finalizer in reverse order.
It returns a boolean (ok) that is true if all Finalizers ran without errors, and the slice of all the Finalizer errors that occurred during execution.
func (*Guillotine) Trigger ¶
func (g *Guillotine) Trigger()
Trigger triggers an asynchronous execution process which will run each Finalizer in reverse order.
Use g.Wait to wait for the execution process to complete.
func (*Guillotine) TriggerOnSignal ¶
func (g *Guillotine) TriggerOnSignal(sig ...os.Signal)
TriggerOnSignal waits for a signal before triggering an execution (see g.Terminate).
func (*Guillotine) TriggerOnTerminate ¶
func (g *Guillotine) TriggerOnTerminate()
TriggerOnTerminate waits for a termination signal (syscall.SIGTERM, syscall.SIGINT) before triggering an exeuction (see g.Terminate).
func (*Guillotine) Wait ¶
func (g *Guillotine) Wait() []error
Wait blocks until the Guillotine completes its asynchronous execution process, and returns the resulting errors from its finalizers.