middleware

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2023 License: Apache-2.0 Imports: 6 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewRPCRetryInterceptor

func NewRPCRetryInterceptor(opt RetryOptions) psrpc.ClientRPCInterceptor

func NewStreamRetryInterceptor

func NewStreamRetryInterceptor(opt RetryOptions) psrpc.StreamInterceptor

func WithClientMetrics

func WithClientMetrics(observer MetricsObserver) psrpc.ClientOption

func WithRPCRetries

func WithRPCRetries(opt RetryOptions) psrpc.ClientOption

func WithServerMetrics

func WithServerMetrics(observer MetricsObserver) psrpc.ServerOption

func WithServerRecovery

func WithServerRecovery() psrpc.ServerRPCInterceptor

Recover from server panics. Should always be the last interceptor

func WithStreamRetries

func WithStreamRetries(opt RetryOptions) psrpc.ClientOption

Types

type MetricRole

type MetricRole int
const (
	ClientRole MetricRole
	ServerRole
)

func (MetricRole) String

func (r MetricRole) String() string

type MetricsObserver

type MetricsObserver interface {
	OnUnaryRequest(role MetricRole, rpcInfo psrpc.RPCInfo, duration time.Duration, err error)
	OnMultiRequest(role MetricRole, rpcInfo psrpc.RPCInfo, duration time.Duration, responseCount int, errorCount int)
	OnStreamSend(role MetricRole, rpcInfo psrpc.RPCInfo, duration time.Duration, err error)
	OnStreamRecv(role MetricRole, rpcInfo psrpc.RPCInfo, err error)
	OnStreamOpen(role MetricRole, rpcInfo psrpc.RPCInfo)
	OnStreamClose(role MetricRole, rpcInfo psrpc.RPCInfo)
}

type RetryOptions

type RetryOptions struct {
	MaxAttempts   int
	Timeout       time.Duration
	Backoff       time.Duration
	IsRecoverable func(err error) bool
}

Jump to

Keyboard shortcuts

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