grpc

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 27, 2025 License: Apache-2.0 Imports: 9 Imported by: 7

Documentation

Overview

Package grpc provides GRPC client/server mixins to add concurrency control.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamServerInterceptor added in v0.1.5

func StreamServerInterceptor(opts ...StreamInterceptorOption) golangGrpc.StreamServerInterceptor

StreamServerInterceptor will add tracing to a gprc streaming client.

func UnaryClientInterceptor

func UnaryClientInterceptor(opts ...InterceptorOption) golangGrpc.UnaryClientInterceptor

UnaryClientInterceptor will add tracing to a gprc client.

func UnaryServerInterceptor

func UnaryServerInterceptor(opts ...InterceptorOption) golangGrpc.UnaryServerInterceptor

UnaryServerInterceptor will trace requests to the given grpc server.

Types

type ClientResponseClassifier

type ClientResponseClassifier func(ctx context.Context, method string, req, reply interface{}, err error) ResponseType

ClientResponseClassifier is a method definition for defining custom response types to the limiter algorithm to correctly handle certain types of errors or embedded data.

type InterceptorOption

type InterceptorOption func(*interceptorConfig)

InterceptorOption represents an option that can be passed to the grpc unary client and server interceptors.

func WithClientResponseTypeClassifier

func WithClientResponseTypeClassifier(classifier ClientResponseClassifier) InterceptorOption

WithClientResponseTypeClassifier sets the response classifier for the intercepted client

func WithLimitExceededResponseClassifier added in v0.1.2

func WithLimitExceededResponseClassifier(classifier LimitExceededResponseClassifier) InterceptorOption

WithLimitExceededResponseClassifier sets the response classifier for the intercepted client

func WithLimiter

func WithLimiter(limiter core.Limiter) InterceptorOption

WithLimiter sets the given limiter for the intercepted client.

func WithName

func WithName(name string) InterceptorOption

WithName sets the default limiter name if the default limiter is used, otherwise unused.

func WithServerResponseTypeClassifier

func WithServerResponseTypeClassifier(classifier ServerResponseClassifier) InterceptorOption

WithServerResponseTypeClassifier sets the response classifier for the intercepted client

func WithStreamTags added in v0.1.5

func WithStreamTags(tags []string) InterceptorOption

WithStreamTags sets the default limiter tags if the default limiter is used, otherwise unused.

func WithTags

func WithTags(tags []string) InterceptorOption

WithTags sets the default limiter tags if the default limiter is used, otherwise unused.

type LimitExceededResponseClassifier added in v0.1.2

type LimitExceededResponseClassifier func(ctx context.Context, method string, req interface{}, l core.Limiter) (interface{}, codes.Code, error)

LimitExceededResponseClassifier is a method definition for defining the error response type when the limit is exceeded and a token is not able to be acquired. By default the RESOURCE_EXHUASTED type is returend.

type ResponseType

type ResponseType int

ResponseType is the type of token release that should be specified to the limiter algorithm.

const (
	// ResponseTypeSuccess represents a successful response for the limiter algorithm
	ResponseTypeSuccess ResponseType = iota
	// ResponseTypeIgnore represents an ignorable error or response for the limiter algorithm
	ResponseTypeIgnore
	// ResponseTypeDropped represents a dropped request type for the limiter algorithm
	ResponseTypeDropped
)

type ServerResponseClassifier

type ServerResponseClassifier func(
	ctx context.Context, req interface{}, info *golangGrpc.UnaryServerInfo, resp interface{}, err error,
) ResponseType

ServerResponseClassifier is a method definition for defining custom response types to the limiter algorithm to correctly handle certain types of errors or embedded data.

type StreamClientResponseClassifier added in v0.1.5

type StreamClientResponseClassifier func(ctx context.Context, req interface{}, info *golangGrpc.StreamServerInfo, err error) ResponseType

StreamClientResponseClassifier is a method definition for defining custom response types to the limiter algorithm to correctly handle certain types of errors or embedded data.

type StreamInterceptorOption added in v0.1.5

type StreamInterceptorOption func(*streamInterceptorConfig)

StreamInterceptorOption represents an option that can be passed to the stream client and server interceptors.

func WithStreamClientResponseTypeClassifier added in v0.1.5

func WithStreamClientResponseTypeClassifier(classifier StreamClientResponseClassifier) StreamInterceptorOption

WithStreamClientResponseTypeClassifier sets the response classifier for the intercepted client response

func WithStreamRecvLimitExceededResponseClassifier added in v0.1.5

func WithStreamRecvLimitExceededResponseClassifier(classifier LimitExceededResponseClassifier) StreamInterceptorOption

WithStreamRecvLimitExceededResponseClassifier sets the response classifier for the intercepted stream client on RecvMsg.

func WithStreamRecvLimiter added in v0.1.5

func WithStreamRecvLimiter(limiter core.Limiter) StreamInterceptorOption

WithStreamRecvLimiter sets the given limiter for the intercepted stream client for RecvMsg.

func WithStreamRecvName added in v0.1.5

func WithStreamRecvName(name string) StreamInterceptorOption

WithStreamRecvName sets the default RecvMsg limiter name if the default limiter is used, otherwise unused.

func WithStreamSendLimitExceededResponseClassifier added in v0.1.5

func WithStreamSendLimitExceededResponseClassifier(classifier LimitExceededResponseClassifier) StreamInterceptorOption

WithStreamSendLimitExceededResponseClassifier sets the response classifier for the intercepted stream client on SendMsg.

func WithStreamSendLimiter added in v0.1.5

func WithStreamSendLimiter(limiter core.Limiter) StreamInterceptorOption

WithStreamSendLimiter sets the given limiter for the intercepted stream client for SendMsg.

func WithStreamSendName added in v0.1.5

func WithStreamSendName(name string) StreamInterceptorOption

WithStreamSendName sets the default SendMsg limiter name if the default limiter is used, otherwise unused.

func WithStreamServerResponseTypeClassifier added in v0.1.5

func WithStreamServerResponseTypeClassifier(classifier StreamServerResponseClassifier) StreamInterceptorOption

WithStreamServerResponseTypeClassifier sets the response classifier for the intercepted server response

type StreamServerResponseClassifier added in v0.1.5

type StreamServerResponseClassifier func(
	ctx context.Context, req interface{}, info *golangGrpc.StreamServerInfo, err error,
) ResponseType

StreamServerResponseClassifier is a method definition for defining custom response types to the limiter algorithm to correctly handle certain types of errors or embedded data.

Jump to

Keyboard shortcuts

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