Documentation
¶
Overview ¶
Package shutdown provides convenient interface for working with os.Signal.
Multiple hooks can be applied, they will be called simultaneously on app shutdown.
Index ¶
- Variables
- func Add(fn func()) string
- func AddWithKey(key string, fn func())
- func AddWithKeyWithParam(key string, fn func(os.Signal))
- func AddWithParam(fn func(os.Signal)) string
- func Hooks() map[string]func(os.Signal)
- func Listen(signals ...os.Signal)
- func Remove(key string)
- func Reset()
- type Shutdown
- func (s *Shutdown) Add(fn func()) string
- func (s *Shutdown) AddWithKey(key string, fn func())
- func (s *Shutdown) AddWithKeyWithParam(key string, fn func(os.Signal))
- func (s *Shutdown) AddWithParam(fn func(os.Signal)) string
- func (s *Shutdown) Hooks() map[string]func(os.Signal)
- func (s *Shutdown) Listen(signals ...os.Signal)
- func (s *Shutdown) Remove(key string)
- func (s *Shutdown) Reset()
Constants ¶
This section is empty.
Variables ¶
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 ¶
AddWithKeyWithParam adds a shutdown hook with signal parameter with provided identificator (key).
func AddWithParam ¶
AddWithParam adds a shutdown hook with signal parameter and returns hook identificator (key).
Types ¶
type Shutdown ¶
type Shutdown struct {
// contains filtered or unexported fields
}
Shutdown is an instance of shutdown handler.
func (*Shutdown) AddWithKey ¶
AddWithKey adds a shutdown hook with provided identificator (key).
func (*Shutdown) AddWithKeyWithParam ¶
AddWithKeyWithParam adds a shutdown hook with signal parameter with provided identificator (key).
func (*Shutdown) AddWithParam ¶
AddWithParam adds a shutdown hook with signal parameter and returns hook identificator (key).
func (*Shutdown) Listen ¶
Listen waits for provided OS signals. It will wait for any signal if no signals provided.