Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Servers)
Option is a function that sets optional parameters for Servers.
func WithLogger ¶
WithLogger sets the Logger instance for logging messages.
func WithRecoverFunc ¶
func WithRecoverFunc(recover func()) Option
WithRecoverFunc sets a function that will be used to recover from panic inside a goroutune that servers are serving requests.
type Server ¶
type Server interface { // Close should stop server from serving all existing requests // and stop accepting new ones. // The listener provided in Serve method must stop listening. Close() error // Shutdown should gracefully stop server. All existing requests // should be processed within a deadline provided by the context. // No new requests should be accepted. // The listener provided in Serve method must stop listening. Shutdown(ctx context.Context) error }
Server defines required methods for a type that can be added to the Servers. In addition to this methods, a Server should implement TCPServer or UDPServer to be able to serve requests.
type Servers ¶
type Servers struct {
// contains filtered or unexported fields
}
Servers holds a list of servers and their options. It provides a simple way to construct server group with Add method, to start them with Serve method, and stop them with Close or Shutdown methods.
func (*Servers) Add ¶
Add adds a new server instance by a custom name and with address to listen to.
func (*Servers) Close ¶
func (s *Servers) Close()
Close stops all servers, by calling Close method on each of them.
func (*Servers) Serve ¶
Serve starts all added servers. New new servers must be added after this methid is called.
func (*Servers) Shutdown ¶
Shutdown gracefully stops all servers, by calling Shutdown method on each of them.