grpc

package module
v0.0.0-...-70b1428 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package grpc implements a run.Group compatible gRPC server.

Index

Constants

View Source
const (
	ServerListenAddress  = "grpc-listen-address"
	MaxGRPCStreamMsgSize = "max-grpc-stream-msg-size"
)

package flags.

Variables

This section is empty.

Functions

func NewStatsHandler

func NewStatsHandler(handlers ...stats.Handler) stats.Handler

NewStatsHandler chains multiple stats.Handler implementations into one.

func StatusError

func StatusError(c codes.Code, msg string) error

StatusError creates a new error embedding a gRPC status code and regular error.

Types

type Interceptors

type Interceptors struct {
	// contains filtered or unexported fields
}

Interceptors holds collections of gRPC server and client interceptors which can be added to and allows them to be chained in a gRPC server or client.

func (*Interceptors) AddServerOption

func (i *Interceptors) AddServerOption(so ...grpc.ServerOption)

AddServerOption allows to add custom server options to a gRPC server.

func (*Interceptors) AddStatsHandler

func (i *Interceptors) AddStatsHandler(handlers ...stats.Handler)

AddStatsHandler allows one or more stats.Handlers to be registered.

func (*Interceptors) AddStreamClient

func (i *Interceptors) AddStreamClient(sc ...grpc.StreamClientInterceptor)

AddStreamClient allows one or more StreamClientInterceptor to be registered.

func (*Interceptors) AddStreamServer

func (i *Interceptors) AddStreamServer(ss ...grpc.StreamServerInterceptor)

AddStreamServer allows one or more StreamServerInterceptor to be registered.

func (*Interceptors) AddUnaryClient

func (i *Interceptors) AddUnaryClient(uc ...grpc.UnaryClientInterceptor)

AddUnaryClient allows one or more UnaryClientInterceptors to be registered.

func (*Interceptors) AddUnaryServer

func (i *Interceptors) AddUnaryServer(us ...grpc.UnaryServerInterceptor)

AddUnaryServer allows one or more UnaryServerInterceptors to be registered.

func (*Interceptors) GetDialOptions

func (i *Interceptors) GetDialOptions() []grpc.DialOption

GetDialOptions returns an array of grpc.DialOptions composed of the registered chained ClientInterceptors.

func (*Interceptors) GetServerOptions

func (i *Interceptors) GetServerOptions() []grpc.ServerOption

GetServerOptions returns an array of grpc.ServerOptions composed of the registered chained ServerInterceptors.

type Service

type Service struct {
	Address              string
	MaxGRPCStreamMsgSize int
	Options              []grpc.ServerOption

	*grpc.Server
	// contains filtered or unexported fields
}

Service implements a run.Group compatible gRPC server.

func (*Service) Attach

func (s *Service) Attach(fn func(*grpc.Server))

Attach allows one to register gRPC services to this server. Once the actual gRPC server is created, the registration function provided to this call will be executed. (during the run.Group Serve stage).

func (*Service) FlagSet

func (s *Service) FlagSet() *run.FlagSet

FlagSet implements run.Config.

func (*Service) GetGrpcAddress

func (s *Service) GetGrpcAddress() (string, error)

GetGrpcAddress returns the grpc address assigned to the server instance. If the address is not configured, an error is returned.

func (*Service) GracefulStop

func (s *Service) GracefulStop()

GracefulStop implements run.Service.

func (*Service) Interceptors

func (s *Service) Interceptors() *Interceptors

Interceptors returns the Interceptors handler for this gRPC Service.

func (*Service) Name

func (s *Service) Name() string

Name implements run.Unit.

func (*Service) Serve

func (s *Service) Serve() error

Serve implements run.Service.

func (*Service) Validate

func (s *Service) Validate() error

Validate implements run.Config.

type StatsHandler

type StatsHandler struct {
	// contains filtered or unexported fields
}

StatsHandler provides the ability to chain multiple grpc/stats.Handler into a single one to be consumed by a gRPC service.

func (*StatsHandler) HandleConn

func (s *StatsHandler) HandleConn(ctx context.Context, cs stats.ConnStats)

HandleConn implements stats.Handler.

func (*StatsHandler) HandleRPC

func (s *StatsHandler) HandleRPC(ctx context.Context, rs stats.RPCStats)

HandleRPC implements stats.Handler.

func (*StatsHandler) TagConn

TagConn implements stats.Handler.

func (*StatsHandler) TagRPC

TagRPC implements stats.Handler.

Directories

Path Synopsis
Package grpcvalidator holds a protoc-gen-validate gRPC server interceptor middleware.
Package grpcvalidator holds a protoc-gen-validate gRPC server interceptor middleware.

Jump to

Keyboard shortcuts

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