middleware

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2024 License: Apache-2.0 Imports: 7 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, rxBytes, txBytes int)
	OnMultiRequest(role MetricRole, rpcInfo psrpc.RPCInfo, duration time.Duration, responseCount, errorCount, rxBytes, txBytes int)
	OnStreamSend(role MetricRole, rpcInfo psrpc.RPCInfo, duration time.Duration, err error, bytes int)
	OnStreamRecv(role MetricRole, rpcInfo psrpc.RPCInfo, err error, bytes int)
	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
	GetRetryParameters func(err error, attempt int) (retry bool, timeout time.Duration, waitTime time.Duration) // will override the MaxAttempts, Timeout and Backoff parameters
}

Jump to

Keyboard shortcuts

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