Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var GracefulStopTimeout = 15 * time.Second
GracefulStopTimeout is the amount of time BoundedGracefulStop will wait before performing a hard server Stop.
Functions ¶
Types ¶
type Server ¶
type Server struct { // CMux wraps a listener 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 // GRPCLoopback is a dialed connection to this GRPCServer. GRPCLoopback *grpc.ClientConn // 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 MustLoopback ¶
func MustLoopback() *Server
MustLoopback builds and returns a new Server instance bound to a random port on the loopback interface. It panics on error.
func New ¶
func New( iface, host, port string, serverTLS, peerTLS *tls.Config, maxGRPCRecvSize uint32, wrapListener func(net.Listener, *tls.Config) (net.Listener, error), ) (*Server, error)
New builds and returns a Server of the given TCP network interface `iface` and `port` for serving traffic directed at `host`. `port` may be empty, in which case a random free port is assigned. if `tlsConfig` is non-nil, the Server uses TLS (and is otherwise in the clear).
func (*Server) BoundedGracefulStop ¶ added in v0.87.3
func (s *Server) BoundedGracefulStop()
BoundedGracefulStop attempts to perform a graceful stop of the server, but falls back to a hard stop if the graceful stop doesn't complete reasonably quickly.
func (*Server) QueueTasks ¶
QueueTasks serving the CMux, HTTP, and gRPC component servers onto the task.Group. If additional Listeners are derived from the Server.CMux, attempts to Accept will block until the CMux itself begins serving.