shutdown

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 6, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GracefulShutdown

type GracefulShutdown struct {
	// contains filtered or unexported fields
}

GracefulShutdown handles ShutdownCallbacks.

func New

func New(timeout time.Duration) *GracefulShutdown

New creates a GracefulShutdown.

func (*GracefulShutdown) AddShutdownCallback

func (gs *GracefulShutdown) AddShutdownCallback(callback ShutdownCallback)

AddShutdownCallback adds a ShutdownCallback that will be called when shutdown is requested.

func (*GracefulShutdown) Shutdown

func (gs *GracefulShutdown) Shutdown()

Shutdown calls all calllbacks, and wait for them to finish.

func (*GracefulShutdown) Start

func (gs *GracefulShutdown) Start()

Start starts listening to shutdown signals.

type ShutdownCallback

type ShutdownCallback interface {
	OnShutdown(ctx context.Context) error
}

ShutdownCallback is an interface you have to implement for callbacks.

type ShutdownFunc

type ShutdownFunc func(context.Context) error

ShutdownFunc is a helper type, so you can easily provide anonymous functions as ShutdownCallbacks like this:

AddShutdownCallback(shutdown.ShutdownFunc(your_callback))

func (ShutdownFunc) OnShutdown

func (f ShutdownFunc) OnShutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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