grpcfx

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoggingInterceptor

func LoggingInterceptor(logger *slog.Logger) grpc.UnaryServerInterceptor

func MetricsInterceptor

func MetricsInterceptor(metrics *Metrics) grpc.UnaryServerInterceptor

Types

type Config

type Config struct {
	Addr                    string        `conf:"ADDR"             default:":9090"`
	Reflection              bool          `conf:"REFLECTION"       default:"true"`
	InitializationTimeout   time.Duration `conf:"INIT_TIMEOUT"     default:"25s"`
	GracefulShutdownTimeout time.Duration `conf:"SHUTDOWN_TIMEOUT" default:"5s"`
}

type GrpcService

type GrpcService struct {
	InnerServer  *grpc.Server
	InnerMetrics *Metrics
	Config       *Config
	// contains filtered or unexported fields
}

func NewGrpcService

func NewGrpcService(config *Config, metricsProvider MetricsProvider, logger *slog.Logger) *GrpcService

func (*GrpcService) RegisterService

func (gs *GrpcService) RegisterService(desc *grpc.ServiceDesc, impl any)

func (*GrpcService) Server

func (gs *GrpcService) Server() *grpc.Server

func (*GrpcService) Start

func (gs *GrpcService) Start(ctx context.Context) (func(), error)

type Metrics

type Metrics struct {
	RequestsTotal   *prometheus.CounterVec
	RequestDuration *prometheus.HistogramVec
	// contains filtered or unexported fields
}

func NewMetrics

func NewMetrics(metricsProvider MetricsProvider) *Metrics

type MetricsProvider

type MetricsProvider interface {
	GetRegistry() *prometheus.Registry
}

Jump to

Keyboard shortcuts

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