interceptor

package
v1.24.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2024 License: MIT Imports: 34 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var (
	ErrNamespaceCountLimitServerBusy = &serviceerror.ResourceExhausted{
		Cause:   enumspb.RESOURCE_EXHAUSTED_CAUSE_CONCURRENT_LIMIT,
		Scope:   enumspb.RESOURCE_EXHAUSTED_SCOPE_NAMESPACE,
		Message: "namespace concurrent poller limit exceeded",
	}
)
View Source
var (
	ErrNamespaceRateLimitServerBusy = &serviceerror.ResourceExhausted{
		Cause:   enumspb.RESOURCE_EXHAUSTED_CAUSE_RPS_LIMIT,
		Scope:   enumspb.RESOURCE_EXHAUSTED_SCOPE_NAMESPACE,
		Message: "namespace rate limit exceeded",
	}
)
View Source
var (
	RateLimitServerBusy = &serviceerror.ResourceExhausted{
		Cause:   enumspb.RESOURCE_EXHAUSTED_CAUSE_RPS_LIMIT,
		Scope:   enumspb.RESOURCE_EXHAUSTED_SCOPE_SYSTEM,
		Message: "service rate limit exceeded",
	}
)

Functions

func FromStatus added in v1.21.0

func FromStatus(st *status.Status) error

FromStatus converts gRPC Status to service error.

func GetMetricsHandlerFromContext added in v1.19.0

func GetMetricsHandlerFromContext(
	ctx context.Context,
	logger log.Logger,
) metrics.Handler

func GetNamespaceName added in v1.20.0

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

func MustGetNamespaceName added in v1.20.0

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

MustGetNamespaceName returns request namespace name or EmptyName if there's error when retriving namespace name, e.g. unable to find namespace

func StreamErrorInterceptor added in v1.21.0

func StreamErrorInterceptor(
	ctx context.Context,
	desc *grpc.StreamDesc,
	cc *grpc.ClientConn,
	method string,
	streamer grpc.Streamer,
	opts ...grpc.CallOption,
) (grpc.ClientStream, error)

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 ClientStreamErrorInterceptor added in v1.21.0

type ClientStreamErrorInterceptor struct {
	grpc.ClientStream
}

func NewClientStreamErrorInterceptor added in v1.21.0

func NewClientStreamErrorInterceptor(
	clientStream grpc.ClientStream,
) *ClientStreamErrorInterceptor

func (*ClientStreamErrorInterceptor) CloseSend added in v1.21.0

func (c *ClientStreamErrorInterceptor) CloseSend() error

func (*ClientStreamErrorInterceptor) RecvMsg added in v1.21.0

func (c *ClientStreamErrorInterceptor) RecvMsg(m interface{}) error

func (*ClientStreamErrorInterceptor) SendMsg added in v1.21.0

func (c *ClientStreamErrorInterceptor) SendMsg(m interface{}) error

type ConcurrentRequestLimitInterceptor added in v1.22.0

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

ConcurrentRequestLimitInterceptor intercepts requests to the server and enforces a limit on the number of requests that can be in-flight at any given time, according to the configured quotas.

func NewConcurrentRequestLimitInterceptor added in v1.22.0

func NewConcurrentRequestLimitInterceptor(
	namespaceRegistry namespace.Registry,
	memberCounter calculator.MemberCounter,
	logger log.Logger,
	perInstanceQuota func(ns string) int,
	globalQuota func(ns string) int,
	tokens map[string]int,
) *ConcurrentRequestLimitInterceptor

func (*ConcurrentRequestLimitInterceptor) Allow added in v1.24.0

func (ni *ConcurrentRequestLimitInterceptor) Allow(
	namespaceName namespace.Name,
	methodName string,
	mh metrics.Handler,
	req any,
) (func(), error)

func (*ConcurrentRequestLimitInterceptor) Intercept added in v1.22.0

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

type ExecutionGetter added in v1.24.0

type ExecutionGetter interface {
	GetExecution() *commonpb.WorkflowExecution
}

type HealthInterceptor added in v1.24.0

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

func NewHealthInterceptor added in v1.24.0

func NewHealthInterceptor() *HealthInterceptor

NewHealthInterceptor returns a new HealthInterceptor. It starts with state not healthy.

func (*HealthInterceptor) Intercept added in v1.24.0

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

func (*HealthInterceptor) SetHealthy added in v1.24.0

func (i *HealthInterceptor) SetHealthy(healthy bool)

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) Allow added in v1.24.0

func (ni *NamespaceRateLimitInterceptor) Allow(namespaceName namespace.Name, methodName string, headerGetter headers.HeaderGetter) error

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 NamespaceValidateIntercept and StateValidationIntercept

func NewNamespaceValidatorInterceptor added in v1.14.0

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

func (*NamespaceValidatorInterceptor) NamespaceValidateIntercept added in v1.20.0

func (ni *NamespaceValidatorInterceptor) NamespaceValidateIntercept(
	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 runs ValidateState - see docstring for that method.

func (*NamespaceValidatorInterceptor) ValidateName added in v1.24.0

func (ni *NamespaceValidatorInterceptor) ValidateName(ns string) error

ValidateName validates a namespace name (currently only a max length check).

func (*NamespaceValidatorInterceptor) ValidateState added in v1.24.0

func (ni *NamespaceValidatorInterceptor) ValidateState(namespaceEntry *namespace.Namespace, fullMethod string) error

ValidateState 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) Allow added in v1.24.0

func (i *RateLimitInterceptor) Allow(
	methodName string,
	headerGetter headers.HeaderGetter,
) error

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 RunIdGetter added in v1.24.0

type RunIdGetter interface {
	GetRunId() string
}

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 TaskTokenGetter added in v1.20.0

type TaskTokenGetter interface {
	GetTaskToken() []byte
}

type TelemetryInterceptor

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

func NewTelemetryInterceptor

func NewTelemetryInterceptor(
	namespaceRegistry namespace.Registry,
	metricsHandler metrics.Handler,
	logger log.Logger,
) *TelemetryInterceptor

func (*TelemetryInterceptor) StreamIntercept added in v1.21.0

func (ti *TelemetryInterceptor) StreamIntercept(
	service interface{},
	serverStream grpc.ServerStream,
	info *grpc.StreamServerInfo,
	handler grpc.StreamHandler,
) error

func (*TelemetryInterceptor) UnaryIntercept added in v1.21.0

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

type WorkflowExecutionGetter added in v1.24.0

type WorkflowExecutionGetter interface {
	GetWorkflowExecution() *commonpb.WorkflowExecution
}

type WorkflowIdGetter added in v1.24.0

type WorkflowIdGetter interface {
	GetWorkflowId() string
}

Jump to

Keyboard shortcuts

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