shutdown

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shutdown provides graceful shutdown orchestration for services.

Index

Constants

View Source
const DefaultShutdownTimeout = 30 * time.Second

DefaultShutdownTimeout is the default time allowed for graceful shutdown.

Variables

This section is empty.

Functions

func Register

func Register(h Handler)

Register adds a shutdown handler. Handlers are called in LIFO order.

func Shutdown

func Shutdown(ctx context.Context) error

Shutdown executes all registered handlers in LIFO order. Returns a combined error if any handler fails.

func WaitForSignal

func WaitForSignal(ctx context.Context) error

WaitForSignal blocks until SIGINT or SIGTERM is received, then calls Shutdown with DefaultShutdownTimeout.

func WaitForSignalWithTimeout

func WaitForSignalWithTimeout(ctx context.Context, timeout time.Duration) error

WaitForSignalWithTimeout blocks until SIGINT or SIGTERM is received, then calls Shutdown with the specified timeout for handlers to complete.

Types

type Handler

type Handler func(ctx context.Context) error

Handler is called during shutdown with the provided context.

Jump to

Keyboard shortcuts

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