grpchelper

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 25 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dial

func Dial(_ context.Context,
	addr string,
	log *slog.Logger,
	metrics *grpc_prometheus.ClientMetrics,
	extraUnary []grpc.UnaryClientInterceptor,
	extraStream []grpc.StreamClientInterceptor,
	extraDialOption []grpc.DialOption,
) (*grpc.ClientConn, error)

Dial creates a gRPC client connection to the given target.

func NewClientMetrics

func NewClientMetrics(reg *prometheus.Registry, namespace, subsystem string) *grpc_prometheus.ClientMetrics

NewClientMetrics returns gRPC client metrics.

func NewLogger

func NewLogger(l *slog.Logger) grpclog.LoggerV2

NewLogger returns new grpclog Logger.

func NewServer

func NewServer(
	m Metrics,
	log *slog.Logger,
	serverMetrics *grpc_prometheus.ServerMetrics,
	converter GRPCCodesConverterHandler,
	extraUnary []grpc.UnaryServerInterceptor,
	extraStream []grpc.StreamServerInterceptor,
) (*grpc.Server, *health.Server)

NewServer creates and returns a gRPC server.

func NewServerMetrics

func NewServerMetrics(reg *prometheus.Registry, namespace, subsystem string) *grpc_prometheus.ServerMetrics

NewServerMetrics returns gRPC server metrics. Do not forget to call .InitializeMetrics(server) on returned value.

func StreamConvertCodesServerInterceptor

func StreamConvertCodesServerInterceptor(converter GRPCCodesConverterHandler) grpc.StreamServerInterceptor

StreamConvertCodesServerInterceptor returns a new unary server interceptor that converting returns error.

func TraceLoggingStreamServerInterceptor

func TraceLoggingStreamServerInterceptor(baseLog *slog.Logger) grpc.StreamServerInterceptor

TraceLoggingStreamServerInterceptor adds trace_id and span_id to the logger in context.

func TraceLoggingUnaryServerInterceptor

func TraceLoggingUnaryServerInterceptor(baseLog *slog.Logger) grpc.UnaryServerInterceptor

TraceLoggingUnaryServerInterceptor adds trace_id and span_id to the logger in context.

func UnaryConvertCodesServerInterceptor

func UnaryConvertCodesServerInterceptor(converter GRPCCodesConverterHandler) grpc.UnaryServerInterceptor

UnaryConvertCodesServerInterceptor returns a new unary server interceptor that converting returns error.

Types

type GRPCCodesConverterHandler

type GRPCCodesConverterHandler = func(error) *status.Status

GRPCCodesConverterHandler is a function that convert your error to gRPC codes. The context can be used to extract request scoped metadata and context values.

type Metrics

type Metrics interface {
	PanicsTotal() prometheus.Counter
}

Metrics provides panic counter for recovery interceptor.

Jump to

Keyboard shortcuts

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