Documentation
¶
Index ¶
- func Dial(_ context.Context, addr string, log *slog.Logger, ...) (*grpc.ClientConn, error)
- func NewClientMetrics(reg *prometheus.Registry, namespace, subsystem string) *grpc_prometheus.ClientMetrics
- func NewLogger(l *slog.Logger) grpclog.LoggerV2
- func NewServer(m Metrics, log *slog.Logger, serverMetrics *grpc_prometheus.ServerMetrics, ...) (*grpc.Server, *health.Server)
- func NewServerMetrics(reg *prometheus.Registry, namespace, subsystem string) *grpc_prometheus.ServerMetrics
- func StreamConvertCodesServerInterceptor(converter GRPCCodesConverterHandler) grpc.StreamServerInterceptor
- func TraceLoggingStreamServerInterceptor(baseLog *slog.Logger) grpc.StreamServerInterceptor
- func TraceLoggingUnaryServerInterceptor(baseLog *slog.Logger) grpc.UnaryServerInterceptor
- func UnaryConvertCodesServerInterceptor(converter GRPCCodesConverterHandler) grpc.UnaryServerInterceptor
- type GRPCCodesConverterHandler
- type Metrics
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 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 ¶
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.