interceptor

package
v1.9.7 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 57 Imported by: 0

Documentation

Overview

Package interceptor is a generated GoMock package.

Package interceptor is a generated GoMock package.

Index

Constants

View Source
const (
	// DCRedirectionPolicyDefault means no redirection
	DCRedirectionPolicyDefault = ""
	// DCRedirectionPolicyNoop means no redirection
	DCRedirectionPolicyNoop = "noop"
	// DCRedirectionPolicySelectedAPIsForwarding means forwarding the following APIs based namespace
	// 1. StartWorkflowExecution
	// 2. SignalWithStartWorkflowExecution
	// 3. SignalWorkflowExecution
	// 4. RequestCancelWorkflowExecution
	// 5. TerminateWorkflowExecution
	// 6. QueryWorkflow
	// please also reference selectedAPIsForwardingRedirectionPolicyWhitelistedAPIs
	DCRedirectionPolicySelectedAPIsForwarding = "selected-apis-forwarding"

	// DCRedirectionPolicyAllAPIsForwarding means forwarding all APIs based on namespace active cluster
	DCRedirectionPolicyAllAPIsForwarding = "all-apis-forwarding"
)
View Source
const (
	// ResourceExhaustedCauseHeader is added to rpc response if request returns ResourceExhausted error.
	ResourceExhaustedCauseHeader = "X-Resource-Exhausted-Cause"

	// ResourceExhaustedScopeHeader is added to rpc response if request returns ResourceExhausted error.
	ResourceExhaustedScopeHeader = "X-Resource-Exhausted-Scope"
)
View Source
const (
	DCRedirectionContextHeaderName = "xdc-redirection"
	DCRedirectionApiHeaderName     = "xdc-redirection-api"
)

Note the nexusoperations component references these headers and adds them to a list of disallowed headers for users to set. If any other headers are added for internal use, they should be added to the disallowed headers list.

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 AddBusinessIDToContext

func AddBusinessIDToContext(ctx context.Context, businessID string) context.Context

AddBusinessIDToContext adds the business ID to the context

func AddTelemetryContext

func AddTelemetryContext(ctx context.Context, metricsHandler metrics.Handler) context.Context

func CreateUnaryMetricsHandlerLogTags

func CreateUnaryMetricsHandlerLogTags(
	baseMetricsHandler metrics.Handler,
	req any,
	fullMethod string,
	methodName string,
	nsName namespace.Name,
) (metrics.Handler, []tag.Tag)

CreateUnaryMetricsHandlerLogTags creates metrics handler and log tags for unary RPC calls

func CustomErrorStreamInterceptor

func CustomErrorStreamInterceptor(
	srv any,
	serverStream grpc.ServerStream,
	info *grpc.StreamServerInfo,
	handler grpc.StreamHandler,
) error

func FromStatus

func FromStatus(st *status.Status) error

FromStatus converts gRPC Status to service error.

func GetBusinessIDFromContext

func GetBusinessIDFromContext(ctx context.Context) string

GetBusinessIDFromContext retrieves the business ID from the context. Returns namespace.EmptyBusinessID if not found.

func GetMetricsHandlerFromContext

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

func GetNamespaceName

func GetNamespaceName(
	namespaceRegistry namespace.Registry,
	req any,
) (namespace.Name, error)

func IsLongPollDescribeActivityExecutionRequest

func IsLongPollDescribeActivityExecutionRequest(
	req any,
) bool

func IsLongPollGetWorkflowExecutionHistoryRequest

func IsLongPollGetWorkflowExecutionHistoryRequest(
	req any,
) bool

func MustGetNamespaceName

func MustGetNamespaceName(
	namespaceRegistry namespace.Registry,
	req any,
) namespace.Name

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

func NewFrontendServiceErrorInterceptor

func NewFrontendServiceErrorInterceptor(
	logger log.Logger,
) grpc.UnaryServerInterceptor

NewFrontendServiceErrorInterceptor returns a gRPC interceptor that has two responsibilities:

  1. Mask certain internal service error details.
  2. Propagate resource exhaustion details via gRPC headers.

func NewHealthSignalAggregator

func NewHealthSignalAggregator(
	logger log.Logger,
	aggregatorEnabled dynamicconfig.BoolPropertyFn,
	windowSize time.Duration,
	maxBufferSize int,
) *healthSignalAggregatorImpl

NewHealthSignalAggregator creates a new instance of HealthSignalAggregatorImpl

func PopulateCallerInfo

func PopulateCallerInfo(
	ctx context.Context,
	nsNameGetter func() string,
	methodGetter func() string,
) context.Context

PopulateCallerInfo gets current caller info value from the context and updates any that are missing. Namespace name and method are passed as functions to avoid expensive lookups if those values are already set.

func ServiceErrorInterceptor

func ServiceErrorInterceptor(
	ctx context.Context,
	req any,
	_ *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

func StreamErrorInterceptor

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

Types

type BusinessIDExtractor

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

func NewBusinessIDExtractor

func NewBusinessIDExtractor() BusinessIDExtractor

func (BusinessIDExtractor) Extract

func (e BusinessIDExtractor) Extract(req any, pattern BusinessIDPattern) string

Extract extracts business ID from the request using the specified pattern. Returns the business ID or namespace.EmptyBusinessID if not found.

type BusinessIDExtractorFunc

type BusinessIDExtractorFunc func(ctx context.Context, req any, fullMethod string) string

BusinessIDExtractorFunc extracts business ID from a request. Returns empty string if this extractor doesn't handle the request.

func WorkflowServiceExtractor

func WorkflowServiceExtractor(extractor BusinessIDExtractor) BusinessIDExtractorFunc

WorkflowServiceExtractor returns a BusinessIDExtractorFunc that extracts business ID from WorkflowService API requests using the provided BusinessIDExtractor.

type BusinessIDInterceptor

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

BusinessIDInterceptor extracts business ID from requests and adds it to context. It iterates through a list of extractor functions until one returns a non-empty business ID.

func NewBusinessIDInterceptor

func NewBusinessIDInterceptor(
	extractors []BusinessIDExtractorFunc,
	logger log.Logger,
) *BusinessIDInterceptor

NewBusinessIDInterceptor creates a new BusinessIDInterceptor with the given extractor functions. Extractors are called in order until one returns a non-empty business ID.

func (*BusinessIDInterceptor) Intercept

func (i *BusinessIDInterceptor) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

Intercept extracts business ID from the request and adds it to the context. It tries each extractor in order until one returns a non-empty business ID.

func (*BusinessIDInterceptor) WithExtractors

func (i *BusinessIDInterceptor) WithExtractors(extractors ...BusinessIDExtractorFunc) *BusinessIDInterceptor

WithExtractors returns a new interceptor with additional extractors prepended. The new extractors will be tried before the existing ones.

type BusinessIDPattern

type BusinessIDPattern int

BusinessIDPattern defines the expected interface pattern for extracting business ID

const (
	// PatternNone indicates no business ID extraction is needed
	PatternNone BusinessIDPattern = iota
	// PatternWorkflowID indicates extraction via GetWorkflowId() method
	PatternWorkflowID
	// PatternWorkflowExecution indicates extraction via GetWorkflowExecution().GetWorkflowId()
	PatternWorkflowExecution
	// PatternExecution indicates extraction via GetExecution().GetWorkflowId()
	PatternExecution
	// PatternTaskToken indicates extraction via deserializing GetTaskToken()
	PatternTaskToken
	// PatternMultiOperation indicates extraction from ExecuteMultiOperationRequest
	PatternMultiOperation
	// PatternTaskQueueName indicates extraction via GetTaskQueue() string method
	PatternTaskQueueName
	// PatternTaskQueueNameFromMessage indicates extraction via GetTaskQueue().GetName() (TaskQueue message)
	PatternTaskQueueNameFromMessage
	// PatternDeploymentName indicates extraction via GetDeploymentName() method
	PatternDeploymentName
	// PatternDeploymentVersion indicates extraction via GetDeploymentVersion().GetDeploymentName()
	PatternDeploymentVersion
	// PatternPollerGroupID indicates extraction via GetPollerGroupId() directly
	PatternPollerGroupID
	// PatternNamespace indicates extraction via GetNamespace() - used when we want to send all calls to a particular api and namespace to a single cell at a time.
	PatternNamespace
	// PatternUpdateRef indicates extraction via GetUpdateRef().GetWorkflowExecution().GetWorkflowId()
	PatternUpdateRef
)

type CallerInfoInterceptor

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

func NewCallerInfoInterceptor

func NewCallerInfoInterceptor(
	namespaceRegistry namespace.Registry,
) *CallerInfoInterceptor

func (*CallerInfoInterceptor) Intercept

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

type ClientStreamErrorInterceptor

type ClientStreamErrorInterceptor struct {
	grpc.ClientStream
}

func NewClientStreamErrorInterceptor

func NewClientStreamErrorInterceptor(
	clientStream grpc.ClientStream,
) *ClientStreamErrorInterceptor

func (*ClientStreamErrorInterceptor) CloseSend

func (c *ClientStreamErrorInterceptor) CloseSend() error

func (*ClientStreamErrorInterceptor) RecvMsg

func (c *ClientStreamErrorInterceptor) RecvMsg(m any) error

func (*ClientStreamErrorInterceptor) SendMsg

func (c *ClientStreamErrorInterceptor) SendMsg(m any) error

type ConcurrentRequestLimitInterceptor

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

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

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

func (*ConcurrentRequestLimitInterceptor) Intercept

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

type DCRedirectionPolicy

type DCRedirectionPolicy interface {
	WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, req any, call func(string) error) error
	WithNamespaceRedirect(ctx context.Context, namespaceName namespace.Name, apiName string, req any, call func(string) error) error
}

DCRedirectionPolicy is a DC redirection policy interface

func RedirectionPolicyGenerator

func RedirectionPolicyGenerator(
	clusterMetadata cluster.Metadata,
	enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	selectedAPIsOnlyForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	namespaceRegistry namespace.Registry,
	policy config.DCRedirectionPolicy,
) DCRedirectionPolicy

RedirectionPolicyGenerator generate corresponding redirection policy

type ErrorHandler

type ErrorHandler interface {
	HandleError(
		req any,
		fullMethod string,
		metricsHandler metrics.Handler,
		logTags []tag.Tag,
		err error,
		nsName namespace.Name,
	)
}

ErrorHandler defines the interface for handling request errors

type HealthCheckInterceptor

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

HealthCheckInterceptor is a gRPC interceptor that records health metrics

func NewHealthCheckInterceptor

func NewHealthCheckInterceptor(healthSignalAggregator HealthSignalAggregator) *HealthCheckInterceptor

NewHealthCheckInterceptor creates a new health check interceptor

func (*HealthCheckInterceptor) UnaryIntercept

func (h *HealthCheckInterceptor) UnaryIntercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

UnaryIntercept implements the gRPC unary interceptor interface

type HealthInterceptor

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

HealthInterceptor rejects frontend requests if the host has not been marked as healthy.

func NewHealthInterceptor

func NewHealthInterceptor() *HealthInterceptor

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

func (*HealthInterceptor) Intercept

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

func (*HealthInterceptor) SetHealthy

func (i *HealthInterceptor) SetHealthy(healthy bool)

type HealthSignalAggregator

type HealthSignalAggregator interface {
	Record(latency time.Duration, err error)
	AverageLatency() float64
	ErrorRatio() float64
}

HealthSignalAggregator interface for aggregating health signals

type MaskInternalErrorDetailsInterceptor

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

func NewMaskInternalErrorDetailsInterceptor

func NewMaskInternalErrorDetailsInterceptor(
	maskErrorSetting dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	namespaceRegistry namespace.Registry,
	logger log.Logger,
) *MaskInternalErrorDetailsInterceptor

func (*MaskInternalErrorDetailsInterceptor) Intercept

func (mi *MaskInternalErrorDetailsInterceptor) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

type MetadataContextInterceptor

type MetadataContextInterceptor struct{}

func NewMetadataContextInterceptor

func NewMetadataContextInterceptor() *MetadataContextInterceptor

NewMetadataContextInterceptor creates a new MetadataContextInterceptor

func (*MetadataContextInterceptor) Intercept

func (m *MetadataContextInterceptor) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

Intercept adds metadata context to all incoming gRPC requests

type MockDCRedirectionPolicy

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

MockDCRedirectionPolicy is a mock of DCRedirectionPolicy interface.

func NewMockDCRedirectionPolicy

func NewMockDCRedirectionPolicy(ctrl *gomock.Controller) *MockDCRedirectionPolicy

NewMockDCRedirectionPolicy creates a new mock instance.

func (*MockDCRedirectionPolicy) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDCRedirectionPolicy) WithNamespaceIDRedirect

func (m *MockDCRedirectionPolicy) WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, req any, call func(string) error) error

WithNamespaceIDRedirect mocks base method.

func (*MockDCRedirectionPolicy) WithNamespaceRedirect

func (m *MockDCRedirectionPolicy) WithNamespaceRedirect(ctx context.Context, namespaceName namespace.Name, apiName string, req any, call func(string) error) error

WithNamespaceRedirect mocks base method.

type MockDCRedirectionPolicyMockRecorder

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

MockDCRedirectionPolicyMockRecorder is the mock recorder for MockDCRedirectionPolicy.

func (*MockDCRedirectionPolicyMockRecorder) WithNamespaceIDRedirect

func (mr *MockDCRedirectionPolicyMockRecorder) WithNamespaceIDRedirect(ctx, namespaceID, apiName, req, call any) *gomock.Call

WithNamespaceIDRedirect indicates an expected call of WithNamespaceIDRedirect.

func (*MockDCRedirectionPolicyMockRecorder) WithNamespaceRedirect

func (mr *MockDCRedirectionPolicyMockRecorder) WithNamespaceRedirect(ctx, namespaceName, apiName, req, call any) *gomock.Call

WithNamespaceRedirect indicates an expected call of WithNamespaceRedirect.

type MockErrorHandler

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

MockErrorHandler is a mock of ErrorHandler interface.

func NewMockErrorHandler

func NewMockErrorHandler(ctrl *gomock.Controller) *MockErrorHandler

NewMockErrorHandler creates a new mock instance.

func (*MockErrorHandler) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockErrorHandler) HandleError

func (m *MockErrorHandler) HandleError(req any, fullMethod string, metricsHandler metrics.Handler, logTags []tag.Tag, err error, nsName namespace.Name)

HandleError mocks base method.

type MockErrorHandlerMockRecorder

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

MockErrorHandlerMockRecorder is the mock recorder for MockErrorHandler.

func (*MockErrorHandlerMockRecorder) HandleError

func (mr *MockErrorHandlerMockRecorder) HandleError(req, fullMethod, metricsHandler, logTags, err, nsName any) *gomock.Call

HandleError indicates an expected call of HandleError.

type NamespaceHandoverInterceptor

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

NamespaceHandoverInterceptor handles the namespace in handover replication state

func NewNamespaceHandoverInterceptor

func NewNamespaceHandoverInterceptor(
	dc *dynamicconfig.Collection,
	namespaceRegistry namespace.Registry,
	metricsHandler metrics.Handler,
	logger log.Logger,
	timeSource clock.TimeSource,
	requestErrorHandler ErrorHandler,
) *NamespaceHandoverInterceptor

func (*NamespaceHandoverInterceptor) Intercept

func (i *NamespaceHandoverInterceptor) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (_ any, retError error)

type NamespaceIDGetter

type NamespaceIDGetter interface {
	GetNamespaceId() string
}

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

type NamespaceLogInterceptor

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

func NewNamespaceLogInterceptor

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

func (*NamespaceLogInterceptor) Intercept

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

type NamespaceNameGetter

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 interface {
	Intercept(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error)
	Allow(namespaceName namespace.Name, methodName string, headerGetter headers.HeaderGetter) error
}

func NewNamespaceRateLimitInterceptor

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

type NamespaceRateLimitInterceptorImpl

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

func (*NamespaceRateLimitInterceptorImpl) Allow

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

func (*NamespaceRateLimitInterceptorImpl) Intercept

func (ni *NamespaceRateLimitInterceptorImpl) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

type NamespaceValidatorInterceptor

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

NamespaceValidatorInterceptor contains NamespaceValidateIntercept and StateValidationIntercept

func NewNamespaceValidatorInterceptor

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

func (*NamespaceValidatorInterceptor) NamespaceValidateIntercept

func (ni *NamespaceValidatorInterceptor) NamespaceValidateIntercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

func (*NamespaceValidatorInterceptor) StateValidationIntercept

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

StateValidationIntercept runs ValidateState - see docstring for that method.

func (*NamespaceValidatorInterceptor) ValidateName

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

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

func (*NamespaceValidatorInterceptor) ValidateState

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 NoopRedirectionPolicy

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

NoopRedirectionPolicy is DC redirection policy which does nothing

func NewNoopRedirectionPolicy

func NewNoopRedirectionPolicy(currentClusterName string) *NoopRedirectionPolicy

NewNoopRedirectionPolicy is DC redirection policy which does nothing

func (*NoopRedirectionPolicy) WithNamespaceIDRedirect

func (policy *NoopRedirectionPolicy) WithNamespaceIDRedirect(_ context.Context, _ namespace.ID, _ string, _ any, call func(string) error) error

WithNamespaceIDRedirect redirect the API call based on namespace ID

func (*NoopRedirectionPolicy) WithNamespaceRedirect

func (policy *NoopRedirectionPolicy) WithNamespaceRedirect(_ context.Context, _ namespace.Name, _ string, _ any, call func(string) error) error

WithNamespaceRedirect redirect the API call based on namespace name

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

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

func (*RateLimitInterceptor) Intercept

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

type Redirection

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

Redirection is simple wrapper over frontend service, doing redirection based on policy

func NewRedirection

func NewRedirection(
	enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	selectedAPIsOnlyForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	namespaceCache namespace.Registry,
	policy config.DCRedirectionPolicy,
	logger log.Logger,
	clientBean client.Bean,
	metricsHandler metrics.Handler,
	timeSource clock.TimeSource,
	clusterMetadata cluster.Metadata,
) *Redirection

NewRedirection creates DC redirection interceptor

func (*Redirection) AfterCall

func (i *Redirection) AfterCall(
	metricsHandler metrics.Handler,
	startTime time.Time,
	targetClusterName string,
	namespaceName string,
	retError error,
)

func (*Redirection) BeforeCall

func (i *Redirection) BeforeCall(
	operation string,
) (metrics.Handler, time.Time)

func (*Redirection) Intercept

func (i *Redirection) Intercept(
	ctx context.Context,
	req any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (_ any, retError error)

func (*Redirection) RedirectionAllowed

func (i *Redirection) RedirectionAllowed(
	ctx context.Context,
) bool

type RequestErrorHandler

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

RequestErrorHandler handles error recording and logging for RPC interceptors

func NewRequestErrorHandler

func NewRequestErrorHandler(
	logger log.Logger,
	logAllReqErrors dynamicconfig.BoolPropertyFnWithNamespaceFilter,
) *RequestErrorHandler

NewRequestErrorHandler creates a new RequestErrorHandler

func (*RequestErrorHandler) HandleError

func (eh *RequestErrorHandler) HandleError(
	req any,
	fullMethod string,
	metricsHandler metrics.Handler,
	logTags []tag.Tag,
	err error,
	nsName namespace.Name,
)

HandleError handles error recording and logging

type RetryableInterceptor

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

func NewRetryableInterceptor

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

func (*RetryableInterceptor) Intercept

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

type SDKVersionInterceptor

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

func NewSDKVersionInterceptor

func NewSDKVersionInterceptor() *SDKVersionInterceptor

NewSDKVersionInterceptor creates a new SDKVersionInterceptor with default max set size

func (*SDKVersionInterceptor) GetAndResetSDKInfo

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

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

func (*SDKVersionInterceptor) Intercept

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

Intercept a grpc request

func (*SDKVersionInterceptor) RecordSDKInfo

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

RecordSDKInfo records name and version tuple in memory

type SelectedAPIsForwardingRedirectionPolicy

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

SelectedAPIsForwardingRedirectionPolicy is a DC redirection policy which (based on namespace) forwards selected APIs calls to active cluster

func NewAllAPIsForwardingPolicy

func NewAllAPIsForwardingPolicy(
	currentClusterName string,
	enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	selectedAPIsOnlyForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	namespaceRegistry namespace.Registry,
) *SelectedAPIsForwardingRedirectionPolicy

NewAllAPIsForwardingPolicy creates a forwarding policy for all APIs based on namespace

func NewSelectedAPIsForwardingPolicy

func NewSelectedAPIsForwardingPolicy(
	currentClusterName string,
	enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	selectedAPIsOnlyForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	namespaceRegistry namespace.Registry,
) *SelectedAPIsForwardingRedirectionPolicy

NewSelectedAPIsForwardingPolicy creates a forwarding policy for selected APIs based on namespace

func (*SelectedAPIsForwardingRedirectionPolicy) WithNamespaceIDRedirect

func (policy *SelectedAPIsForwardingRedirectionPolicy) WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, _ any, call func(string) error) error

WithNamespaceIDRedirect redirect the API call based on namespace ID

func (*SelectedAPIsForwardingRedirectionPolicy) WithNamespaceRedirect

func (policy *SelectedAPIsForwardingRedirectionPolicy) WithNamespaceRedirect(ctx context.Context, namespaceName namespace.Name, apiName string, _ any, call func(string) error) error

WithNamespaceRedirect redirect the API call based on namespace name

type SlowRequestLoggerInterceptor

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

func NewSlowRequestLoggerInterceptor

func NewSlowRequestLoggerInterceptor(
	logger log.Logger,
	slowRequestThreshold dynamicconfig.DurationPropertyFn,
) *SlowRequestLoggerInterceptor

func (*SlowRequestLoggerInterceptor) Intercept

func (i *SlowRequestLoggerInterceptor) Intercept(
	ctx context.Context,
	request any,
	info *grpc.UnaryServerInfo,
	handler grpc.UnaryHandler,
) (any, error)

type TaskTokenGetter

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,
	logAllReqErrors dynamicconfig.BoolPropertyFnWithNamespaceFilter,
	requestErrorHandler ErrorHandler,
) *TelemetryInterceptor

func (*TelemetryInterceptor) RecordLatencyMetrics

func (ti *TelemetryInterceptor) RecordLatencyMetrics(ctx context.Context, startTime time.Time, metricsHandler metrics.Handler)

func (*TelemetryInterceptor) StreamIntercept

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

func (*TelemetryInterceptor) UnaryIntercept

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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