shutdown

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package shutdown provides graceful shutdown handling for applications.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Timeout time.Duration
	Signals []os.Signal
}

Config configures shutdown behavior.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns sensible defaults.

type Handler

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

Handler manages graceful shutdown.

func New

func New(cfg Config) *Handler

New creates a new shutdown handler.

func (*Handler) Listen

func (h *Handler) Listen() context.Context

Listen starts listening for shutdown signals. Returns a context that will be cancelled on shutdown.

func (*Handler) Register

func (h *Handler) Register(fn func(ctx context.Context) error)

Register adds a shutdown hook.

func (*Handler) Trigger

func (h *Handler) Trigger()

Trigger manually triggers shutdown.

func (*Handler) Wait

func (h *Handler) Wait()

Wait blocks until shutdown is complete.

Jump to

Keyboard shortcuts

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