Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error string
Error represents a package level error. Implements builtin error interface.
const ( // ErrGracefullyShutdown represents an error message // indicating the failure to gracefully shut down a listener. ErrGracefullyShutdown Error = "shut down listener gracefully" // ErrCertPathRequired represents an error message // indicating that a certificate file path is required. ErrCertPathRequired Error = "certificate file path is required" // ErrPrivateKeyPathRequired represents an error message // indicating that a private key file path is required. ErrPrivateKeyPathRequired Error = "private key file path is required" )
type Listener ¶
type Listener interface { // Serve runs the listener, handling incoming requests. It takes a context as an argument // and returns an error if an error occurs while serving requests. Serve(ctx context.Context) error }
Listener is an interface that represents a listener which can serve requests. It requires the implementation of the Serve method that takes a context and returns an error.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a type that represents a server that holds a map of listeners.
func NewServer ¶
NewServer creates a new Server instance with an empty listeners map and returns a pointer to the created Server.
func (*Server) RegisterListener ¶
RegisterListener adds a listener to the Server's listeners map.
func (*Server) Serve ¶
Serve runs the server and serves requests from all listeners. It creates an error group and a listener context. It iterates through the listeners map and starts a goroutine for each listener. Each goroutine retries calling the listener's Serve method until it succeeds or the retry limit is reached. If the Serve method returns an error, it logs an error message and checks if the error is retryable. If the context is canceled, it returns the context error. If the retry limit is reached, it returns ErrRetryLimitReached. Finally, it waits for all goroutines to complete and returns any error encountered during serving.
Directories ¶
Path | Synopsis |
---|---|
dbkit
|
|
Package idkit provides the set of functions to generate different kind of identifiers.
|
Package idkit provides the set of functions to generate different kind of identifiers. |