rpcserver

package
v3.24.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 35 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 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 WithRateLimiter added in v3.12.0

func WithRateLimiter(limiter ratelimit.Interface) Option

WithRateLimiter configures a rate limiter on the server.

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 WithTrustedProxies added in v3.10.2

func WithTrustedProxies(cidrs ...string) Option

WithTrustedProxies adds trusted proxies from which proxy headers are trusted.

func WithUnaryInterceptors

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

WithUnaryInterceptors adds gRPC unary interceptors

type Registerer

type Registerer interface {
	Roles() []ttnpb.ClusterRole
	ServiceRegisterer
}

Registerer extends ServiceRegisterer with the cluster roles fulfilled by the component.

type Server

type Server struct {
	*grpc.Server
	*hooks.Hooks
	*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

type ServiceRegisterer added in v3.17.2

type ServiceRegisterer interface {
	RegisterServices(s *grpc.Server)
	RegisterHandlers(s *runtime.ServeMux, conn *grpc.ClientConn)
}

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

Jump to

Keyboard shortcuts

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