interceptor

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ErrDomainMetrics = "metrics"

Variables

This section is empty.

Functions

This section is empty.

Types

type Meters

type Meters struct {
	// contains filtered or unexported fields
}

Meters helps with collecting metrics for prometheus from grpc.

func InitMeters

func InitMeters(ctx context.Context, cfgApp *commoncfg.Application, meter metric.Meter) (*Meters, error)

func (*Meters) StreamInterceptor

func (m *Meters) StreamInterceptor(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamInterceptor tracks the duration and count of streaming gRPC calls.

func (*Meters) UnaryInterceptor

func (m *Meters) UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (any, error)

UnaryInterceptor tracks the duration and count of unary gRPC calls.

type Recover

type Recover struct{}

Recover helps in recovering panics grpc endpoints. we could also add a client to notify in the future.

func NewRecover

func NewRecover() *Recover

NewRecover will create a Recover instance. Recover as both Unary and Stream interceptor for server. More information about the interceptors can be found here. https://grpc.io/docs/guides/interceptors

func (*Recover) StreamInterceptor

func (r *Recover) StreamInterceptor(srv any, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) (err error)

StreamInterceptor intercepts for any panics, and helps our server to recover. Note: It is better to add this as the last interceptor.

func (*Recover) UnaryInterceptor

func (r *Recover) UnaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (_ any, err error)

UnaryInterceptor intercepts for any panics, and helps our server to recover. Note: It is better to add this as the last interceptor.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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