grpcserver

package
v0.11.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

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
	// Services is a list of service names to declare as SERVING in health
	// checks. Names should be fully-qualified (package_name.service_name, e.g.
	// vtadmin.VTAdminServer, not VTAdminServer), and must be unique for a
	// single Server instance. Users of this package are responsible for
	// ensuring they do not pass a list with duplicate service names.
	//
	// The service name "grpc.health.v1.Health" is reserved by this package in
	// order to power the healthcheck service. Attempting to pass this in the
	// Services list to a grpcserver will be ignored.
	//
	// See https://github.com/grpc/grpc/blob/7324556353e831c57d30973db33df489c3ed3576/doc/health-checking.md
	// for more details on healthchecking.
	Services []string
}

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

func New(name string, opts Options) *Server

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.

func (*Server) GRPCServer

func (s *Server) GRPCServer() *grpc.Server

GRPCServer returns the gRPC Server.

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

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.

func (*Server) Router

func (s *Server) Router() *mux.Router

Router returns the mux.Router powering the HTTP side of the server.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL