grpcutil

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2024 License: MIT Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClientConn

func NewClientConn(
	ctx context.Context,
	cfg ClientConnConfig,
) (grpc.ClientConnInterface, error)

Types

type ClientConnConfig

type ClientConnConfig struct {
	// Config required that defines a client connection.
	// Validate isn't ran here, it assumes that the config has been
	// validated during the parsing phase.
	Config configmodels.GRPCClient

	// StreamInterceptors adds stream interceptors, thhey run at the very last
	// beofre the important interceptors are added.
	StreamInterceptors []grpc.StreamClientInterceptor

	// UnaryInterceptors adds unary interceptors, alike the stream interceptors
	// they run at the very last before the important interceptors are added.
	UnaryInterceptors []grpc.UnaryClientInterceptor

	// EnableTelemtry if true, it includes the opentelemtry interceptors
	// to both the unary and stream operations.
	EnableTelemtry bool
}

type GRPCTransport

type GRPCTransport struct {
	Server *grpc.Server
	Config configmodels.GRPCServerTransport
}

GRPCTransport represents a built grpc server along with the transport configuration used to build it.

func NewTransports

func NewTransports(cfg TransportBuilderConfig) (transports []*GRPCTransport, err error)

NewTransports based on the provided configuration builds multiple transports no services are registered so it's important that one iterates through the transports once created and registers accordingly.

func (*GRPCTransport) Listener

func (s *GRPCTransport) Listener() (net.Listener, error)

Listener attempts to create a net.Listener.

type TransportBuilderConfig

type TransportBuilderConfig struct {
	// Config required to build the transports.
	// Validate isn't ran here, it assumes that the config has been
	// validated during the parsing phase.
	Config configmodels.GRPCServer
	// StreamInterceptors adds stream interceptors, they run at the very last
	// before the important interceptors are added.
	StreamInterceptors []grpc.StreamServerInterceptor
	// UnaryInterceptors adds unary interceptors, as the stream interceptor
	// they run at the very last before the important interceptors are added.
	UnaryInterceptors []grpc.UnaryServerInterceptor
	// EnableTelemetry if true, it includes opentelemetry interceptors
	// to both the unary and stream operations.
	EnableTelemetry bool
	// ServerOptions are hopefully, options which won't be used during the
	// transport building, such as a load balancer policy.
	ServerOptions []grpc.ServerOption
	// RecoveryOptions are options passed to the recoverer middleware
	RecoveryOptions []recoverygrpc.Option
	// OtelOptions are options passed to the otelgrpc middleware, only applicable
	// if EnableTelemetry is true
	OtelOptions []otelgrpc.Option
}

TransportBuilderConfig defines the configuration used to build the transports.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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