grpcserver

package
v0.35.1-crescendo-prev... Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GrpcServer

type GrpcServer struct {
	component.Component

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

GrpcServer wraps `grpc.Server` and allows to manage it using `component.Component` interface. It can be injected into different engines making it possible to use single grpc server for multiple services which live in different modules.

func NewGrpcServer

func NewGrpcServer(log zerolog.Logger,
	grpcListenAddr string,
	grpcServer *grpc.Server,
	grpcSignalerCtx *atomic.Pointer[irrecoverable.SignalerContext],
) *GrpcServer

NewGrpcServer returns a new grpc server.

func (*GrpcServer) GRPCAddress

func (g *GrpcServer) GRPCAddress() net.Addr

GRPCAddress returns the listen address of the GRPC server. Guaranteed to be non-nil after Engine.Ready is closed.

type GrpcServerBuilder

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

GrpcServerBuilder created for separating the creation and starting GrpcServer, cause services need to be registered before the server starts.

func NewGrpcServerBuilder

func NewGrpcServerBuilder(log zerolog.Logger,
	gRPCListenAddr string,
	maxMsgSize uint,
	rpcMetricsEnabled bool,
	apiRateLimits map[string]int,
	apiBurstLimits map[string]int,
	opts ...Option,
) *GrpcServerBuilder

NewGrpcServerBuilder creates a new builder for configuring and initializing a gRPC server.

The builder is configured with the provided parameters such as logger, gRPC server address, maximum message size, API rate limits, and additional options. The builder also sets up the necessary interceptors, including handling irrecoverable errors using the irrecoverable.SignalerContext. The gRPC server can be configured with options such as maximum message sizes and interceptors for handling RPC calls.

If RPC metrics are enabled, the builder adds the gRPC Prometheus interceptor for collecting metrics. Additionally, it can enable a state stream interceptor based on the configuration. Rate limiting interceptors can be added based on specified API rate limits. Logging and custom interceptors are applied, and the final gRPC server is returned.

If transport credentials are provided, a secure gRPC server is created; otherwise, an unsecured server is initialized.

Note: The gRPC server is created with the specified options and is ready for further configuration or starting.

func (*GrpcServerBuilder) Build

func (b *GrpcServerBuilder) Build() *GrpcServer

type Option

type Option func(*GrpcServerBuilder)

func WithStreamInterceptor

func WithStreamInterceptor() Option

WithStreamInterceptor sets the StreamInterceptor option to grpc server.

func WithTransportCredentials

func WithTransportCredentials(transportCredentials credentials.TransportCredentials) Option

WithTransportCredentials sets the transport credentials parameters for a grpc server builder.

Jump to

Keyboard shortcuts

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