Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct { // RawListener is the bound TCP listener of the Server. RawListener *net.TCPListener // CMux wraps RawListener to provide connection protocol multiplexing over // a single bound socket. gRPC and HTTP Listeners are provided by default. // Additional Listeners may be added directly via CMux.Match() -- though // it is then the user's responsibility to Serve the resulting Listeners. CMux cmux.CMux // GRPCListener is a CMux Listener for gRPC connections. GRPCListener net.Listener // HTTPListener is a CMux Listener for HTTP connections. HTTPListener net.Listener // HTTPMux is the http.ServeMux which is served by Serve(). HTTPMux *http.ServeMux // GRPCServer is the gRPC server mux which is served by Serve(). GRPCServer *grpc.Server // Ctx is cancelled when Server.GracefulStop is called. Ctx context.Context // contains filtered or unexported fields }
Server bundles gRPC & HTTP servers, multiplexed over a single bound TCP socket (using CMux). Additional protocols may be added to the Server by interacting directly with its provided CMux.
func New ¶
New builds and returns a Server of the given TCP network interface |iface| and |port|. |port| may be zero, in which case a random free port is assigned.
func (*Server) GRPCLoopback ¶
func (s *Server) GRPCLoopback() (*grpc.ClientConn, error)
GRPCLoopback dials and returns a connection to the local gRPC server.
func (*Server) GracefulStop ¶
func (s *Server) GracefulStop()
GracefulStop the Server. Attempts to Accept() connections from CMux Listeners may begin failing after a GracefulStop call is started. The Server.Ctx may be inspected to determine if the Server is stopping. Returns when server stop is complete.
func (*Server) MustGRPCLoopback ¶
func (s *Server) MustGRPCLoopback() *grpc.ClientConn
MustGRPCLoopback dials and returns a connection to the local gRPC server, and panics on error.
func (*Server) MustServe ¶
func (s *Server) MustServe()
MustServe calls Serve, and panics on an encountered error.
func (*Server) Serve ¶
Serve the Server, including the CMux, HTTP Server, and gRPC server. The first encountered error is returned. If additional Listeners have been derived from the Server.CMux, Serve must first be called to begin serving the CMux itself, and then connections may be Accept()'d from the derived Listeners.