proxy.golang.org : github.com/go-pkgz/ctrl
Package ctrl provides a set of control functions for assertions, error handling, HTTP server management, and graceful shutdown handling in Go applications. Built for Go 1.21+, it offers a clean API with flexible configuration options and no external runtime dependencies. The package provides assertion functions that panic when conditions are not met, useful for runtime invariant checking: For scenarios where returning an error is more appropriate than panicking, the package provides ErrorOr variants: The package helps manage HTTP server lifecycle, particularly graceful shutdown: The package provides robust handling of process termination signals: Use assertions for internal invariants that should never fail in correct code: Use ErrorOr variants for validating external input or recoverable conditions: For HTTP servers, combine graceful shutdown with server lifecycle management: Example_gracefulShutdown demonstrates basic usage of the GracefulShutdown function. Example_gracefulShutdownCustomConfiguration demonstrates custom shutdown configuration. Example_gracefulShutdownWithCallbacks demonstrates using callbacks during shutdown. Example_httpServerWithContext demonstrates how to run an HTTP server that shuts down gracefully when the parent context is canceled.
Registry
-
Source
- Documentation
- JSON
- codemeta.json
purl: pkg:golang/github.com/go-pkgz/ctrl
Keywords:
asssertions
, control-flow
, golang
, shutdown
License: MIT
Latest release: 4 months ago
First release: 9 months ago
Namespace: github.com/go-pkgz
Stars: 4 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Funding links: https://github.com/sponsors/umputun
Last synced: 18 days ago