shutdown

package
v1.0.0-rc9 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultShutdown = New()

DefaultShutdown is a default instance.

Functions

func Add

func Add(fn func()) string

Add adds a shutdown hook and returns hook identificator (key).

func AddWithKey

func AddWithKey(key string, fn func())

AddWithKey adds a shutdown hook with provided identificator (key).

func AddWithKeyWithParam

func AddWithKeyWithParam(key string, fn func(os.Signal))

AddWithKeyWithParam adds a shutdown hook with signal parameter with provided identificator (key).

func AddWithParam

func AddWithParam(fn func(os.Signal)) string

AddWithParam adds a shutdown hook with signal parameter and returns hook identificator (key).

func Hooks

func Hooks() map[string]func(os.Signal)

Hooks returns a copy of current hooks.

func Listen

func Listen(signals ...os.Signal)

Listen waits for provided OS signals. It will wait for any signal if no signals provided.

func Remove

func Remove(key string)

Remove cancels hook by identificator (key).

func Reset

func Reset()

Reset cancels all hooks.

Types

type Shutdown

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

Shutdown is an instance of shutdown handler.

func New

func New() *Shutdown

New creates a new Shutdown instance.

func (*Shutdown) Add

func (s *Shutdown) Add(fn func()) string

Add adds a shutdown hook and returns hook identificator (key).

func (*Shutdown) AddWithKey

func (s *Shutdown) AddWithKey(key string, fn func())

AddWithKey adds a shutdown hook with provided identificator (key).

func (*Shutdown) AddWithKeyWithParam

func (s *Shutdown) AddWithKeyWithParam(key string, fn func(os.Signal))

AddWithKeyWithParam adds a shutdown hook with signal parameter with provided identificator (key).

func (*Shutdown) AddWithParam

func (s *Shutdown) AddWithParam(fn func(os.Signal)) string

AddWithParam adds a shutdown hook with signal parameter and returns hook identificator (key).

func (*Shutdown) Hooks

func (s *Shutdown) Hooks() map[string]func(os.Signal)

Hooks returns a copy of current hooks.

func (*Shutdown) Listen

func (s *Shutdown) Listen(signals ...os.Signal)

Listen waits for provided OS signals. It will wait for any signal if no signals provided.

func (*Shutdown) Remove

func (s *Shutdown) Remove(key string)

Remove cancels hook by identificator (key).

func (*Shutdown) Reset

func (s *Shutdown) Reset()

Reset cancels all hooks.

Jump to

Keyboard shortcuts

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