shutdown

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

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 to terminate "at leisure", 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 immediate, 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 closed down, which is made by the component and can be used from outside to determine whether the component has finished terminating.

func NewSignaller

func NewSignaller() *Signaller

NewSignaller creates a new signaller.

func (*Signaller) CloseAtLeisure

func (s *Signaller) CloseAtLeisure()

CloseAtLeisure 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.

func (*Signaller) CloseAtLeisureChan

func (s *Signaller) CloseAtLeisureChan() <-chan struct{}

CloseAtLeisureChan returns a channel that will be closed when the signal to shut down either at leisure or immediately has been made.

func (*Signaller) CloseAtLeisureCtx

func (s *Signaller) CloseAtLeisureCtx(ctx context.Context) (context.Context, context.CancelFunc)

CloseAtLeisureCtx returns a context.Context that will be terminated when either the provided context is cancelled or the signal to shut down either at leisure or immediately has been made.

func (*Signaller) CloseNow

func (s *Signaller) CloseNow()

CloseNow signals to the owner of this Signaller that it should terminate right now regardless of any in progress tasks.

func (*Signaller) CloseNowChan

func (s *Signaller) CloseNowChan() <-chan struct{}

CloseNowChan returns a channel that will be closed when the signal to shut down immediately has been made.

func (*Signaller) CloseNowCtx

func (s *Signaller) CloseNowCtx(ctx context.Context) (context.Context, context.CancelFunc)

CloseNowCtx returns a context.Context that will be terminated when either the provided context is cancelled or the signal to shut down immediately has been made.

func (*Signaller) HasClosed

func (s *Signaller) HasClosed() bool

HasClosed returns true if the signaller has received the signal that the component has terminated.

func (*Signaller) HasClosedChan

func (s *Signaller) HasClosedChan() <-chan struct{}

HasClosedChan returns a channel that will be closed when the signal that the component has terminated has been made.

func (*Signaller) HasClosedCtx

func (s *Signaller) HasClosedCtx(ctx context.Context) (context.Context, context.CancelFunc)

HasClosedCtx returns a context.Context that will be cancelled when either the provided context is cancelled or the signal that the component has shut down has been made.

func (*Signaller) ShouldCloseAtLeisure

func (s *Signaller) ShouldCloseAtLeisure() bool

ShouldCloseAtLeisure returns true if the signaller has received the signal to shut down at leisure or immediately.

func (*Signaller) ShouldCloseNow

func (s *Signaller) ShouldCloseNow() bool

ShouldCloseNow returns true if the signaller has received the signal to shut down immediately.

func (*Signaller) ShutdownComplete

func (s *Signaller) ShutdownComplete()

ShutdownComplete is a signal made by the component that it and all of its owned resources have terminated.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL