graceful

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package graceful has tools for making graceful shutdown.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCallbackCnt = errors.New("invalid callbacks count, required only start and stop callbacks") //nolint:revive
	ErrStartFunc   = errors.New("invalid start func")                                              //nolint:revive
	ErrStopFunc    = errors.New("invalid stop func")                                               //nolint:revive
)

Functions

func Init

func Init(ctx context.Context, signals ...os.Signal) (context.Context, context.CancelFunc)

Init subscribes to os signals and registers cancel func and group context.

func Register

func Register(funcs ...Callback) error

Register registers some service to listen and its "stop" function.

func Wait

func Wait() error

Wait registers executor for "stop" callbacks and blocks until all registered callbacks will end.

Types

type Callback

type Callback func() error

Callback is a common function type.

Jump to

Keyboard shortcuts

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