graceful

package
v0.89.2 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterServer

func RegisterServer(server Server)

see [handler.RegisterServer].

func RegisterServerFunc

func RegisterServerFunc(name string, serveFunc func(ctx context.Context) error, shutdownFunc func(ctx context.Context) error)

see [handler.RegisterServerFunc].

func RegistryShutdownFunc

func RegistryShutdownFunc(name string, f func())

RegistryShutdownFunc registers function called on shutdown to default handler.

func SafeGo

func SafeGo(wg *sync.WaitGroup, log *slog.Logger, f func())

SafeGo starts a new goroutine and adds it to wg. it also recovers from any panic in the goroutine and logs it using the provided logger.

func Serve

func Serve(log *slog.Logger) error

see [handler.Serve].

Types

type Server

type Server interface {
	// Name returns the name of the server, used for logging and debugging purposes.
	Name() string
	// Shutdown gracefully shuts down the server without interrupting any active connections.
	Shutdown(ctx context.Context) error
	// Serve starts the server and blocks until the server is stopped or an error occurs.
	// if the server is stopped gracefully, it should return nil.
	// If the server is stopped due to an error, it should return the error.
	// if any server is stopped, all servers will be stopped gracefully.
	Serve(ctx context.Context) error
}

func NewHttpServer

func NewHttpServer(name string, server *http.Server) Server

Jump to

Keyboard shortcuts

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