Documentation ¶
Index ¶
Constants ¶
View Source
const ( PriorityIngress = 100 PriorityJobs = 500 PriorityCritical = 1000 )
Some helper priority levels
Variables ¶
View Source
var Shutdown = sync.OnceFunc(func() { logger.Infof("begin shutdown") for len(shutdownTaskRegistry) > 0 { _task := heap.Pop(&shutdownTaskRegistry) if _task == nil { break } task := _task.(ShutdownTask) logger.Infof("shutting down: %s", task.Label) s := time.Now() task.Hook() logger.Infof("shutdown %s completed in %v", task.Label, time.Since(s)) } })
Functions ¶
func AddHook ¶
func AddHook(fn shutdownHook)
Add a hook with the least priority. Least priority hooks are run first.
Prefer AddHookWithPriority()
func AddHookWithPriority ¶ added in v1.0.730
AddHookWithPriority adds a hook with a priority level.
Execution order goes from lowest to highest priority numbers.
func ShutdownAndExit ¶
func WaitForSignal ¶
func WaitForSignal()
Types ¶
type ShutdownTask ¶ added in v1.0.730
type ShutdownTasks ¶ added in v1.0.730
type ShutdownTasks []ShutdownTask
ShutdownTasks implements heap.Interface
func (ShutdownTasks) Len ¶ added in v1.0.730
func (st ShutdownTasks) Len() int
func (ShutdownTasks) Less ¶ added in v1.0.730
func (st ShutdownTasks) Less(i, j int) bool
func (*ShutdownTasks) Pop ¶ added in v1.0.730
func (st *ShutdownTasks) Pop() interface{}
func (*ShutdownTasks) Push ¶ added in v1.0.730
func (st *ShutdownTasks) Push(x interface{})
func (ShutdownTasks) Swap ¶ added in v1.0.730
func (st ShutdownTasks) Swap(i, j int)
Click to show internal directories.
Click to hide internal directories.