rpcserver

package
v3.9.3 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2020 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Overview

Package rpcserver initializes The Things Network's base gRPC server

Index

Constants

This section is empty.

Variables

View Source
var ErrRPCRecovered = errors.DefineInternal("rpc_recovered", "Internal Server Error")

ErrRPCRecovered is returned when a panic is caught from an RPC.

Functions

func StartLoopback

func StartLoopback(ctx context.Context, s *grpc.Server, opts ...grpc.DialOption) (*grpc.ClientConn, error)

StartLoopback starts the server on a local address and returns a connection to that address. This function does not add the default DialOptions.

Types

type Option

type Option func(*options)

Option for the gRPC server

func WithContextFiller

func WithContextFiller(contextFillers ...fillcontext.Filler) Option

WithContextFiller sets a context filler

func WithFieldExtractor

func WithFieldExtractor(fieldExtractor grpc_ctxtags.RequestFieldExtractorFunc) Option

WithFieldExtractor sets a field extractor

func WithLogIgnoreMethods added in v3.9.0

func WithLogIgnoreMethods(methods []string) Option

WithLogIgnoreMethods sets a list of methods for which no log messages are printed on success.

func WithServerOptions

func WithServerOptions(serverOptions ...grpc.ServerOption) Option

WithServerOptions adds gRPC ServerOptions

func WithStreamInterceptors

func WithStreamInterceptors(interceptors ...grpc.StreamServerInterceptor) Option

WithStreamInterceptors adds gRPC stream interceptors

func WithUnaryInterceptors

func WithUnaryInterceptors(interceptors ...grpc.UnaryServerInterceptor) Option

WithUnaryInterceptors adds gRPC unary interceptors

type Registerer

type Registerer interface {
	Roles() []ttnpb.ClusterRole
	RegisterServices(s *grpc.Server)
	RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)
}

Registerer allows components to register their services to the gRPC server and the HTTP gateway

type Server

type Server struct {
	*grpc.Server
	*runtime.ServeMux
	// contains filtered or unexported fields
}

Server wraps the gRPC server

func New

func New(ctx context.Context, opts ...Option) *Server

New returns a new RPC server with a set of middlewares. The given context is used in some of the middlewares, the given server options are passed to gRPC

Currently the following middlewares are included: tag extraction, metrics, logging, sending errors to Sentry, validation, errors, panic recovery

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP forwards requests to the gRPC gateway

Jump to

Keyboard shortcuts

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