Documentation
¶
Index ¶
- Variables
- type GracefulShutdown
- type ServerManager
- func (sm *ServerManager) ServersStarted() <-chan struct{}
- func (sm *ServerManager) StartWithGracefulShutdown()
- func (sm *ServerManager) StartWithGracefulShutdownWithError() error
- func (sm *ServerManager) WithGRPCServer(server *grpc.Server, address string) *ServerManager
- func (sm *ServerManager) WithHTTPServer(app *fiber.App, address string) *ServerManager
- func (sm *ServerManager) WithShutdownChannel(ch <-chan struct{}) *ServerManager
Constants ¶
This section is empty.
Variables ¶
var ErrNoServersConfigured = errors.New("no servers configured: use WithHTTPServer() or WithGRPCServer()")
ErrNoServersConfigured indicates no servers were configured for the manager
Functions ¶
This section is empty.
Types ¶
type GracefulShutdown ¶
type GracefulShutdown struct {
// contains filtered or unexported fields
}
GracefulShutdown handles the graceful shutdown of application components. It's designed to be reusable across different services. Deprecated: Use ServerManager instead for better coordination.
func NewGracefulShutdown ¶
func NewGracefulShutdown( app *fiber.App, grpcServer *grpc.Server, licenseClient *license.ManagerShutdown, telemetry *opentelemetry.Telemetry, logger log.Logger, ) *GracefulShutdown
NewGracefulShutdown creates a new instance of GracefulShutdown. Deprecated: Use NewServerManager instead for better coordination.
func (*GracefulShutdown) HandleShutdown ¶
func (gs *GracefulShutdown) HandleShutdown()
HandleShutdown sets up signal handling and executes the shutdown sequence when a termination signal is received. Deprecated: Use ServerManager.StartWithGracefulShutdown() instead.
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
ServerManager handles the graceful shutdown of multiple server types. It can manage HTTP servers, gRPC servers, or both simultaneously.
func NewServerManager ¶
func NewServerManager( licenseClient *license.ManagerShutdown, telemetry *opentelemetry.Telemetry, logger log.Logger, ) *ServerManager
NewServerManager creates a new instance of ServerManager.
func (*ServerManager) ServersStarted ¶
func (sm *ServerManager) ServersStarted() <-chan struct{}
ServersStarted returns a channel that is closed when server goroutines have been launched. Note: This signals that goroutines were spawned, not that sockets are bound and ready to accept connections. This is useful for tests to coordinate shutdown timing after server launch.
func (*ServerManager) StartWithGracefulShutdown ¶
func (sm *ServerManager) StartWithGracefulShutdown()
StartWithGracefulShutdown initializes all configured servers and sets up graceful shutdown. It terminates the process with os.Exit(1) if no servers are configured (backward compatible behavior). Note: On configuration error, logFatal always terminates the process regardless of logger availability. Use StartWithGracefulShutdownWithError() for proper error handling without process termination.
func (*ServerManager) StartWithGracefulShutdownWithError ¶
func (sm *ServerManager) StartWithGracefulShutdownWithError() error
StartWithGracefulShutdownWithError validates configuration and starts servers. Returns an error if no servers are configured instead of calling Fatal. Blocks until shutdown signal is received or shutdown channel is closed.
func (*ServerManager) WithGRPCServer ¶
func (sm *ServerManager) WithGRPCServer(server *grpc.Server, address string) *ServerManager
WithGRPCServer configures the gRPC server for the ServerManager.
func (*ServerManager) WithHTTPServer ¶
func (sm *ServerManager) WithHTTPServer(app *fiber.App, address string) *ServerManager
WithHTTPServer configures the HTTP server for the ServerManager.
func (*ServerManager) WithShutdownChannel ¶
func (sm *ServerManager) WithShutdownChannel(ch <-chan struct{}) *ServerManager
WithShutdownChannel configures a custom shutdown channel for the ServerManager. This allows tests to trigger shutdown deterministically instead of relying on OS signals.