Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Options ¶
type Options struct { // Addr is the network address to listen on. Addr string // CMuxReadTimeout bounds the amount of time spent muxing connections between // gRPC and HTTP. A zero-value specifies unbounded muxing. CMuxReadTimeout time.Duration // LameDuckDuration specifies the length of the lame duck period during // graceful shutdown. If non-zero, the Server will mark itself unhealthy to // stop new incoming connections while continuing to serve existing // connections. LameDuckDuration time.Duration // AllowReflection specifies whether to register the gRPC server for // reflection. This is required to use with tools like grpc_cli. AllowReflection bool // EnableTracing specifies whether to install opentracing interceptors on // the gRPC server. EnableTracing bool // EnableChannelz specifies whether to register the channelz service on the // gRPC server. EnableChannelz bool // MetricsEndpoint is the route to serve promhttp metrics on, including // those collected be grpc_prometheus interceptors. // // It is the user's responsibility to ensure this does not conflict with // other endpoints. // // Omit to not export metrics. MetricsEndpoint string StreamInterceptors []grpc.StreamServerInterceptor UnaryInterceptors []grpc.UnaryServerInterceptor }
Options defines the set of configurations for a gRPC server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server provides a multiplexed gRPC/HTTP server.
func New ¶
New returns a new server. See Options for documentation on configuration options.
The underlying gRPC server always has the following interceptors:
- prometheus
- recovery: this handles recovering from panics.
The full list of interceptors is as follows: - (optional) interceptors defined on the Options struct - prometheus - (optional) opentracing, if opts.EnableTracing is set - recovery
func (*Server) GRPCServer ¶
GRPCServer returns the gRPC Server.
func (*Server) ListenAndServe ¶
ListenAndServe sets up a listener, multiplexes it into gRPC and non-gRPC requests, and binds the gRPC server and mux.Router to them, respectively. It then installs a signal handler on SIGTERM and SIGQUIT, and runs until either a signal or an unrecoverable error occurs.
On shutdown, it may begin a lame duck period (see Options) before beginning a graceful shutdown of the gRPC server and closing listeners.
func (*Server) MustListenAndServe ¶
func (s *Server) MustListenAndServe()
MustListenAndServe calls ListenAndServe and panics if an error occurs.