Documentation ¶
Index ¶
- type Signaller
- func (s *Signaller) HardStopChan() <-chan struct{}
- func (s *Signaller) HardStopCtx(ctx context.Context) (context.Context, context.CancelFunc)
- func (s *Signaller) HasStoppedChan() <-chan struct{}
- func (s *Signaller) HasStoppedCtx(ctx context.Context) (context.Context, context.CancelFunc)
- func (s *Signaller) IsHardStopSignalled() bool
- func (s *Signaller) IsHasStoppedSignalled() bool
- func (s *Signaller) IsSoftStopSignalled() bool
- func (s *Signaller) SoftStopChan() <-chan struct{}
- func (s *Signaller) SoftStopCtx(ctx context.Context) (context.Context, context.CancelFunc)
- func (s *Signaller) TriggerHardStop()
- func (s *Signaller) TriggerHasStopped()
- func (s *Signaller) TriggerSoftStop()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Signaller ¶
type Signaller struct {
// contains filtered or unexported fields
}
Signaller is a mechanism owned by components that support graceful shut down and is used as a way to signal from outside that any goroutines owned by the component should begin to close.
Shutting down can happen in two tiers of urgency, the first is a "soft stop", meaning if you're in the middle of something it's okay to do that first before terminating, but please do not commit to new work.
The second tier is a "hard stop", where you need to clean up resources and terminate as soon as possible, regardless of any tasks that you are currently attempting to finish.
Finally, there is also a signal of having stopped, which is made by the component and can be used from outside to determine whether the component has finished terminating.
func (*Signaller) HardStopChan ¶
func (s *Signaller) HardStopChan() <-chan struct{}
HardStopChan returns a channel that will be closed when the signal to hard stop has been made.
func (*Signaller) HardStopCtx ¶
HardStopCtx returns a context.Context that will be terminated when either the provided context is cancelled or the signal to hard stop has been made.
func (*Signaller) HasStoppedChan ¶
func (s *Signaller) HasStoppedChan() <-chan struct{}
HasStoppedChan returns a channel that will be closed when the signal that the component has stopped has been made.
func (*Signaller) HasStoppedCtx ¶
HasStoppedCtx returns a context.Context that will be cancelled when either the provided context is cancelled or the signal that the component has stopped has been made.
func (*Signaller) IsHardStopSignalled ¶
IsHardStopSignalled returns true if the signaller has received the signal to hard stop.
func (*Signaller) IsHasStoppedSignalled ¶
IsHasStoppedSignalled returns true if the signaller has received the signal that the component has stopped.
func (*Signaller) IsSoftStopSignalled ¶
IsSoftStopSignalled returns true if the signaller has received the signal to soft stop.
func (*Signaller) SoftStopChan ¶
func (s *Signaller) SoftStopChan() <-chan struct{}
SoftStopChan returns a channel that will be closed when the signal to soft or hard stop has been made.
func (*Signaller) SoftStopCtx ¶
SoftStopCtx returns a context.Context that will be terminated when either the provided context is cancelled or the signal to soft or hard stop has been made.
func (*Signaller) TriggerHardStop ¶
func (s *Signaller) TriggerHardStop()
TriggerHardStop signals to the owner of this Signaller that it should terminate right now regardless of any in progress tasks.
func (*Signaller) TriggerHasStopped ¶
func (s *Signaller) TriggerHasStopped()
TriggerHasStopped is a signal made by the component that it and all of its owned resources have terminated.
func (*Signaller) TriggerSoftStop ¶
func (s *Signaller) TriggerSoftStop()
TriggerSoftStop signals to the owner of this Signaller that it should terminate at its own leisure, meaning it's okay to complete any tasks that are in progress but no new work should be started.