Documentation
¶
Overview ¶
Package service provides a Group type for managing multiple HTTP servers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNilServer = errors.New("server is nil")
ErrNilServer indicates that the server instance is nil and cannot be used.
var ErrNoServers = errors.New("no servers configured")
ErrNoServers represents an error indicating that no servers have been configured.
var ErrServerNameLenMismatch = errors.New("server and name length mismatch")
ErrServerNameLenMismatch indicates a mismatch between the lengths of the server and name values.
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a collection of HTTP servers managed together with shared lifecycle controls.
func NewGroup ¶
NewGroup creates and returns a new Group, applying the provided options. Returns an error if any option fails.
func (*Group) ServerCount ¶
ServerCount gives the current number of running servers in the group. This value is volatile and should be used only for informational purposes, e.g. display to the user.
func (*Group) StartAll ¶
StartAll starts all configured servers and returns once all listen sockets are bound. It does not block; use WaitAllServersShutdown() to wait for completion.
func (*Group) WaitAllServersShutdown ¶
func (g *Group) WaitAllServersShutdown()
WaitAllServersShutdown waits for all running servers goroutines to complete and their shutdown processes using ShutdownWhenDone, before continuing execution.
type Option ¶
Option is a function that configures a Group by applying custom settings or modifications.
func WithLogger ¶
WithLogger sets a custom logger for the Group and returns an Option for configuration.
func WithServer ¶
WithServer adds an HTTP server with a specified name to the group for management and lifecycle control.
func WithServers ¶
WithServers adds the provided HTTP servers and their corresponding names to the Group configuration.
func WithShutdownTimeout ¶
WithShutdownTimeout sets a timeout duration for server shutdown within the Group and returns an Option.