Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNoService = errors.New("no service is running")
Functions ¶
func StartServers ¶ added in v0.3.0
StartServers is responsible for starting the provided servers concurrently and managing their lifecycle events such as interrupts or failures. The function will ensure that if any server fails or if there is an external interrupt, all servers will be gracefully shut down.
Parameters:
- ctx: Context that allows for asynchronous task cancellation.
- logger: A pointer to a logging instance of type *log.ZapEventLogger.
- servers: A variadic parameter that lists all the server instances that need to be started.
Returns:
- error: The error encountered during the operation, if any.
The function uses channels to listen for events like server failure or external interrupts (like Ctrl+C) and ensures all servers are gracefully terminated before exiting.
Types ¶
type Server ¶ added in v0.3.0
type Server interface { // Start Starts the server and returns two channels. The Done channels are closed when the server is done running, // and the Fail channel receives an error if the server fails. The method also returns an error immediately // if the server fails to start. The server runs until the provided context is cancelled. Start(ctx context.Context) ([]Done, Fail, error) // Name returns the name of the server. Name() string }
Server is an interface that represents a server that can be started and has a name.
Click to show internal directories.
Click to hide internal directories.