interceptor

package
v1.18.3 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NamespaceRateLimitDefaultToken = 1
)
View Source
const (
	RateLimitDefaultToken = 1
)

Variables

View Source
var (
	ErrNamespaceCountLimitServerBusy = serviceerror.NewResourceExhausted(enumspb.RESOURCE_EXHAUSTED_CAUSE_CONCURRENT_LIMIT, "namespace concurrent poller limit exceeded")
)
View Source
var (
	ErrNamespaceNotSet = serviceerror.NewInvalidArgument("Namespace not set on request.")
)
View Source
var (
	ErrNamespaceRateLimitServerBusy = serviceerror.NewResourceExhausted(enumspb.RESOURCE_EXHAUSTED_CAUSE_RPS_LIMIT, "namespace rate limit exceeded")
)
View Source
var (
	RateLimitServerBusy = serviceerror.NewResourceExhausted(enumspb.RESOURCE_EXHAUSTED_CAUSE_RPS_LIMIT, "service rate limit exceeded")
)

Functions

func GetNamespace

func GetNamespace(
	namespaceRegistry namespace.Registry,
	req interface{},
) namespace.Name

func MetricsScope

func MetricsScope(
	ctx context.Context,
	logger log.Logger,
) metrics.Scope

Types

type CallerInfoInterceptor added in v1.17.2

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

func NewCallerInfoInterceptor added in v1.17.2

func NewCallerInfoInterceptor(
	namespaceRegistry namespace.Registry,
) *CallerInfoInterceptor

func (*CallerInfoInterceptor) Intercept added in v1.17.2

func (i *CallerInfoInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

type NamespaceCountLimitInterceptor

type NamespaceCountLimitInterceptor struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewNamespaceCountLimitInterceptor

func NewNamespaceCountLimitInterceptor(
	namespaceRegistry namespace.Registry,
	logger log.Logger,
	countFn func(namespace string) int,
	tokens map[string]int,
) *NamespaceCountLimitInterceptor

func (*NamespaceCountLimitInterceptor) Intercept

func (ni *NamespaceCountLimitInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

type NamespaceIDGetter added in v1.8.1

type NamespaceIDGetter interface {
	GetNamespaceId() string
}

gRPC method request must implement either NamespaceNameGetter or NamespaceIDGetter for namespace specific metrics to be reported properly

type NamespaceLogInterceptor added in v1.11.0

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

func NewNamespaceLogInterceptor added in v1.11.0

func NewNamespaceLogInterceptor(namespaceRegistry namespace.Registry, logger log.Logger) *NamespaceLogInterceptor

func (*NamespaceLogInterceptor) Intercept added in v1.11.0

func (nli *NamespaceLogInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

type NamespaceNameGetter added in v1.8.1

type NamespaceNameGetter interface {
	GetNamespace() string
}

gRPC method request must implement either NamespaceNameGetter or NamespaceIDGetter for namespace specific metrics to be reported properly

type NamespaceRateLimitInterceptor

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

func NewNamespaceRateLimitInterceptor

func NewNamespaceRateLimitInterceptor(
	namespaceRegistry namespace.Registry,
	rateLimiter quotas.RequestRateLimiter,
	tokens map[string]int,
) *NamespaceRateLimitInterceptor

func (*NamespaceRateLimitInterceptor) Intercept

func (ni *NamespaceRateLimitInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

type NamespaceValidatorInterceptor added in v1.14.0

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

NamespaceValidatorInterceptor contains LengthValidationIntercept and StateValidationIntercept

func NewNamespaceValidatorInterceptor added in v1.14.0

func NewNamespaceValidatorInterceptor(
	namespaceRegistry namespace.Registry,
	enableTokenNamespaceEnforcement dynamicconfig.BoolPropertyFn,
	maxNamespaceLength dynamicconfig.IntPropertyFn,
) *NamespaceValidatorInterceptor

func (*NamespaceValidatorInterceptor) LengthValidationIntercept added in v1.18.1

func (ni *NamespaceValidatorInterceptor) LengthValidationIntercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

func (*NamespaceValidatorInterceptor) StateValidationIntercept added in v1.18.1

func (ni *NamespaceValidatorInterceptor) StateValidationIntercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

StateValidationIntercept validates: 1. Namespace is specified in task token if there is a `task_token` field. 2. Namespace is specified in request if there is a `namespace` field and no `task_token` field. 3. Namespace exists. 4. Namespace from request match namespace from task token, if check is enabled with dynamic config. 5. Namespace is in correct state.

type RateLimitInterceptor

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

func NewRateLimitInterceptor

func NewRateLimitInterceptor(
	rateLimiter quotas.RequestRateLimiter,
	tokens map[string]int,
) *RateLimitInterceptor

func (*RateLimitInterceptor) Intercept

func (i *RateLimitInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

type RetryableInterceptor added in v1.17.3

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

func NewRetryableInterceptor added in v1.17.3

func NewRetryableInterceptor(
	policy backoff.RetryPolicy,
	isRetryable backoff.IsRetryable,
) *RetryableInterceptor

func (*RetryableInterceptor) Intercept added in v1.17.3

func (i *RetryableInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

type SDKVersionInterceptor added in v1.15.0

type SDKVersionInterceptor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewSDKVersionInterceptor added in v1.15.0

func NewSDKVersionInterceptor() *SDKVersionInterceptor

NewSDKVersionInterceptor creates a new SDKVersionInterceptor with default max set size

func (*SDKVersionInterceptor) GetAndResetSDKInfo added in v1.15.0

func (vi *SDKVersionInterceptor) GetAndResetSDKInfo() []check.SDKInfo

GetAndResetSDKInfo gets all recorded name, version tuples and resets internal records

func (*SDKVersionInterceptor) Intercept added in v1.15.0

func (vi *SDKVersionInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

Intercept a grpc request

func (*SDKVersionInterceptor) RecordSDKInfo added in v1.15.0

func (vi *SDKVersionInterceptor) RecordSDKInfo(name, version string)

RecordSDKInfo records name and version tuple in memory

type TelemetryInterceptor

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

func NewTelemetryInterceptor

func NewTelemetryInterceptor(
	namespaceRegistry namespace.Registry,
	metricsClient metrics.Client,
	scopes map[string]int,
	logger log.Logger,
) *TelemetryInterceptor

func (*TelemetryInterceptor) Intercept

func (ti *TelemetryInterceptor) Intercept(
	ctx context.Context,
	req interface{},
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (interface{}, error)

Jump to

Keyboard shortcuts

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