graceful

package
v1.2.115 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 5 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Graceful

func Graceful(ctx context.Context, handlers ...Handler) (err error)

Graceful sets up graceful handling of context done, typically for an HTTP server. When context is done, the shutdown handler will be invoked with a context. Example:

ctx is wrapped WithShutdownSignal(ctx)
When signal is trapped, the shutdown handler will be invoked with a context.

Types

type Handler

type Handler struct {
	Name         string       // server name
	StartFunc    StartFunc    // func to start the server
	ShutdownFunc ShutdownFunc // func to shutdown the server
}

type ShutdownFunc

type ShutdownFunc func(context.Context) error

ShutdownFunc is the type of the function invoked by Graceful to shutdown the server

type StartFunc

type StartFunc func(context.Context) error

StartFunc is the type of the function invoked by Graceful to start the server

Jump to

Keyboard shortcuts

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