Documentation
¶
Overview ¶
Package serverz is a web app toolkit to easily manage server based environments
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GrpcServer ¶ added in v0.2.0
GrpcServer implements the Server interface for a gRPC server
func (*GrpcServer) Close ¶ added in v0.2.0
func (s *GrpcServer) Close() error
Close implements Server
type NamedServer ¶
NamedServer can be used to parametrize logs
type Server ¶
type Server interface { // Serve accepts incoming connections on the Listener l. // // Serve always returns a non-nil error. Serve(l net.Listener) error // Shutdown gracefully shuts down the server without interrupting any // active connections. Shutdown works by first closing all open // listeners, then closing all idle connections, and then waiting // indefinitely for connections to return to idle and then shut down. // If the provided context expires before the shutdown is complete, // then the context's error is returned. Shutdown(ctx context.Context) error // Close immediately closes all active net.Listeners. // // For a graceful shutdown, use Shutdown. Close() error }
Server in this context is an abstraction over anything that can be started and stopped (either gracefully or forcefully) Typically they accept connections and serve over network, like HTTP or RPC servers
type ServerManager ¶
type ServerManager struct {
// contains filtered or unexported fields
}
ServerManager manages multiple Servers' lifecycle
func NewServerManager ¶
func NewServerManager(logger logrus.FieldLogger) *ServerManager
NewServerManager creates a new ServerManager
func (*ServerManager) ListenAndStartServer ¶
func (sm *ServerManager) ListenAndStartServer(server Server, addr string) func(ch chan<- error)
ListenAndStartServer creates a server starter function which listens on a port and can be called as a goroutine
func (*ServerManager) StartServer ¶
func (sm *ServerManager) StartServer(server Server, listener net.Listener) func(ch chan<- error)
StartServer creates a server starter function which can be called as a goroutine
func (*ServerManager) StopServer ¶
StopServer creates a server stopper function which can be called as a goroutine