Documentation
¶
Index ¶
- Constants
- func Contains(list []string, item string) bool
- func CtxLogger(ctx context.Context) *log.Logger
- func CtxTracer(ctx context.Context) oteltrace.Tracer
- func Unique(list []string) []string
- type DefaultGrpcServerFactory
- type GrpcHealthCheckService
- type GrpcLoggerInterceptor
- func (i *GrpcLoggerInterceptor) Exclude(methods ...string) *GrpcLoggerInterceptor
- func (i *GrpcLoggerInterceptor) Metadata(metadata map[string]string) *GrpcLoggerInterceptor
- func (i *GrpcLoggerInterceptor) StreamInterceptor() grpc.StreamServerInterceptor
- func (i *GrpcLoggerInterceptor) UnaryInterceptor() grpc.UnaryServerInterceptor
- type GrpcPanicRecoveryHandler
- type GrpcServerFactory
- type GrpcServerOption
- type Options
Constants ¶
const ( HeaderXRequestId = "x-request-id" LogFieldRequestId = "requestID" )
const TracerName = "grpcserver"
TracerName is the grpcserver tracer name.
Variables ¶
This section is empty.
Functions ¶
func CtxLogger ¶
CtxLogger returns the contextual log.Logger.
func CtxTracer ¶
CtxTracer returns the contextual oteltrace.Tracer.
Types ¶
type DefaultGrpcServerFactory ¶
type DefaultGrpcServerFactory struct{}
DefaultGrpcServerFactory is the default GrpcServerFactory implementation.
func (*DefaultGrpcServerFactory) Create ¶
func (f *DefaultGrpcServerFactory) Create(options ...GrpcServerOption) (*grpc.Server, error)
Create returns a new grpc.Server, and accepts an optional list of GrpcServerOption.
type GrpcHealthCheckService ¶
type GrpcHealthCheckService struct { grpc_health_v1.UnimplementedHealthServer // contains filtered or unexported fields }
GrpcHealthCheckService is a default gRPC health check server implementation working with the healthcheck.Checker.
func NewGrpcHealthCheckService ¶
func NewGrpcHealthCheckService(checker *healthcheck.Checker) *GrpcHealthCheckService
NewGrpcHealthCheckService returns a new GrpcHealthCheckService instance.
func (*GrpcHealthCheckService) Check ¶
func (s *GrpcHealthCheckService) Check(ctx context.Context, in *grpc_health_v1.HealthCheckRequest) (*grpc_health_v1.HealthCheckResponse, error)
Check performs checks on the registered healthcheck.CheckerProbe.
func (*GrpcHealthCheckService) Watch ¶
func (s *GrpcHealthCheckService) Watch(in *grpc_health_v1.HealthCheckRequest, watchServer grpc_health_v1.Health_WatchServer) error
Watch is not implemented.
type GrpcLoggerInterceptor ¶
type GrpcLoggerInterceptor struct {
// contains filtered or unexported fields
}
GrpcLoggerInterceptor is a gRPC unary and stream server interceptor to produce correlated logs.
func NewGrpcLoggerInterceptor ¶
func NewGrpcLoggerInterceptor(generator uuid.UuidGenerator, logger *log.Logger) *GrpcLoggerInterceptor
NewGrpcLoggerInterceptor returns a new GrpcLoggerInterceptor instance.
func (*GrpcLoggerInterceptor) Exclude ¶
func (i *GrpcLoggerInterceptor) Exclude(methods ...string) *GrpcLoggerInterceptor
Exclude configures a list of method names to exclude from logging.
func (*GrpcLoggerInterceptor) Metadata ¶
func (i *GrpcLoggerInterceptor) Metadata(metadata map[string]string) *GrpcLoggerInterceptor
Metadata configures a list of metadata to log from incoming context.
func (*GrpcLoggerInterceptor) StreamInterceptor ¶
func (i *GrpcLoggerInterceptor) StreamInterceptor() grpc.StreamServerInterceptor
StreamInterceptor handles the stream requests.
func (*GrpcLoggerInterceptor) UnaryInterceptor ¶
func (i *GrpcLoggerInterceptor) UnaryInterceptor() grpc.UnaryServerInterceptor
UnaryInterceptor handles the unary requests.
type GrpcPanicRecoveryHandler ¶
type GrpcPanicRecoveryHandler struct{}
GrpcPanicRecoveryHandler is used to recover panics with the recovery interceptor.
func NewGrpcPanicRecoveryHandler ¶
func NewGrpcPanicRecoveryHandler() *GrpcPanicRecoveryHandler
NewGrpcPanicRecoveryHandler returns a new GrpcPanicRecoveryHandler instance.
func (*GrpcPanicRecoveryHandler) Handle ¶
func (h *GrpcPanicRecoveryHandler) Handle(withDebug bool) recovery.RecoveryHandlerFuncContext
Handle handles the panic recovery.
type GrpcServerFactory ¶
type GrpcServerFactory interface {
Create(options ...GrpcServerOption) (*grpc.Server, error)
}
GrpcServerFactory is the interface for grpc.Server factories.
func NewDefaultGrpcServerFactory ¶
func NewDefaultGrpcServerFactory() GrpcServerFactory
NewDefaultGrpcServerFactory returns a DefaultGrpcServerFactory, implementing GrpcServerFactory.
type GrpcServerOption ¶
type GrpcServerOption func(o *Options)
GrpcServerOption are functional options for the GrpcServerFactory implementations.
func WithReflection ¶
func WithReflection(r bool) GrpcServerOption
WithReflection is used to enable gRPC server reflection.
func WithServerOptions ¶
func WithServerOptions(s ...grpc.ServerOption) GrpcServerOption
WithServerOptions is used to configure a list of grpc.ServerOption.
type Options ¶
type Options struct { ServerOptions []grpc.ServerOption Reflection bool }
Options are options for the GrpcServerFactory implementations.
func DefaultGrpcServerOptions ¶
func DefaultGrpcServerOptions() Options
DefaultGrpcServerOptions are the default options used in the DefaultGrpcServerFactory.