shutdown

package
v1.21.21 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	PriorityIngress  = 0
	PriorityDefault  = 100
	PriorityWorkers  = 200
	PriorityDatabase = 300
	PriorityCritical = 400
)

Variables

This section is empty.

Functions

func AddHook

func AddHook(label string, fn func())

AddHook registers a shutdown hook with default priority

func AddHookWithPriority

func AddHookWithPriority(label string, priority int, fn func())

AddHookWithPriority registers a shutdown hook with specific priority

func RecoverAndShutdown

func RecoverAndShutdown()

RecoverAndShutdown is intended to be deferred in main(). On panic it runs all shutdown hooks and restores terminal state, then re-panics so the stack trace is preserved.

func RunAndWait

func RunAndWait(fn func() error) error

RunAndWait runs the provided function and then waits for shutdown signal

func SetTerminalRestoreFunc

func SetTerminalRestoreFunc(fn func())

SetTerminalRestoreFunc registers a callback that performs full terminal state restoration (e.g. term.Restore with saved state). Called automatically during Shutdown, force-exit, and RecoverAndShutdown.

func Shutdown

func Shutdown()

Shutdown executes all registered hooks in priority order

func WaitForSignal

func WaitForSignal()

WaitForSignal waits for interrupt signals and triggers shutdown

Types

type Hook

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

type HookHeap

type HookHeap []*Hook

func (HookHeap) Len

func (h HookHeap) Len() int

func (HookHeap) Less

func (h HookHeap) Less(i, j int) bool

func (*HookHeap) Pop

func (h *HookHeap) Pop() interface{}

func (*HookHeap) Push

func (h *HookHeap) Push(x interface{})

func (HookHeap) Swap

func (h HookHeap) Swap(i, j int)

Jump to

Keyboard shortcuts

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