Documentation ¶
Overview ¶
Package interceptor is a generated GoMock package.
Index ¶
- Constants
- Variables
- func AddTelemetryContext(ctx context.Context, metricsHandler metrics.Handler) context.Context
- func FromStatus(st *status.Status) error
- func GetMetricsHandlerFromContext(ctx context.Context, logger log.Logger) metrics.Handler
- func GetNamespaceName(namespaceRegistry namespace.Registry, req interface{}) (namespace.Name, error)
- func MustGetNamespaceName(namespaceRegistry namespace.Registry, req interface{}) namespace.Name
- func PopulateCallerInfo(ctx context.Context, nsNameGetter func() string, methodGetter func() string) context.Context
- func StreamErrorInterceptor(ctx context.Context, desc *grpc.StreamDesc, cc *grpc.ClientConn, method string, ...) (grpc.ClientStream, error)
- type CallerInfoInterceptor
- type ClientStreamErrorInterceptor
- type ConcurrentRequestLimitInterceptor
- type DCRedirectionPolicy
- type HealthInterceptor
- type MaskInternalErrorDetailsInterceptor
- type MockDCRedirectionPolicy
- func (m *MockDCRedirectionPolicy) EXPECT() *MockDCRedirectionPolicyMockRecorder
- func (m *MockDCRedirectionPolicy) WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, ...) error
- func (m *MockDCRedirectionPolicy) WithNamespaceRedirect(ctx context.Context, namespace namespace.Name, apiName string, ...) error
- type MockDCRedirectionPolicyMockRecorder
- type NamespaceIDGetter
- type NamespaceLogInterceptor
- type NamespaceNameGetter
- type NamespaceRateLimitInterceptor
- type NamespaceValidatorInterceptor
- func (ni *NamespaceValidatorInterceptor) NamespaceValidateIntercept(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func (ni *NamespaceValidatorInterceptor) StateValidationIntercept(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, ...) (interface{}, error)
- func (ni *NamespaceValidatorInterceptor) ValidateName(ns string) error
- func (ni *NamespaceValidatorInterceptor) ValidateState(namespaceEntry *namespace.Namespace, fullMethod string) error
- type NoopRedirectionPolicy
- type RateLimitInterceptor
- type Redirection
- func (i *Redirection) AfterCall(metricsHandler metrics.Handler, startTime time.Time, clusterName string, ...)
- func (i *Redirection) BeforeCall(operation string) (metrics.Handler, time.Time)
- func (i *Redirection) Intercept(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (_ any, retError error)
- func (i *Redirection) RedirectionAllowed(ctx context.Context) bool
- type RetryableInterceptor
- type SDKVersionInterceptor
- type SelectedAPIsForwardingRedirectionPolicy
- func (policy *SelectedAPIsForwardingRedirectionPolicy) WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, ...) error
- func (policy *SelectedAPIsForwardingRedirectionPolicy) WithNamespaceRedirect(ctx context.Context, namespace namespace.Name, apiName string, ...) error
- type TaskTokenGetter
- type TelemetryInterceptor
- func (ti *TelemetryInterceptor) HandleError(req any, fullMethod string, metricsHandler metrics.Handler, logTags []tag.Tag, ...)
- func (ti *TelemetryInterceptor) RecordLatencyMetrics(ctx context.Context, startTime time.Time, metricsHandler metrics.Handler)
- func (ti *TelemetryInterceptor) StreamIntercept(service any, serverStream grpc.ServerStream, info *grpc.StreamServerInfo, ...) error
- func (ti *TelemetryInterceptor) UnaryIntercept(ctx context.Context, req any, info *grpc.UnaryServerInfo, ...) (any, error)
Constants ¶
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" )
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.
const (
NamespaceRateLimitDefaultToken = 1
)
const (
RateLimitDefaultToken = 1
)
Variables ¶
var ( ErrNamespaceCountLimitServerBusy = &serviceerror.ResourceExhausted{ Cause: enumspb.RESOURCE_EXHAUSTED_CAUSE_CONCURRENT_LIMIT, Scope: enumspb.RESOURCE_EXHAUSTED_SCOPE_NAMESPACE, Message: "namespace concurrent poller limit exceeded", } )
var ( ErrNamespaceRateLimitServerBusy = &serviceerror.ResourceExhausted{ Cause: enumspb.RESOURCE_EXHAUSTED_CAUSE_RPS_LIMIT, Scope: enumspb.RESOURCE_EXHAUSTED_SCOPE_NAMESPACE, Message: "namespace rate limit exceeded", } )
var ( RateLimitServerBusy = &serviceerror.ResourceExhausted{ Cause: enumspb.RESOURCE_EXHAUSTED_CAUSE_RPS_LIMIT, Scope: enumspb.RESOURCE_EXHAUSTED_SCOPE_SYSTEM, Message: "service rate limit exceeded", } )
Functions ¶
func AddTelemetryContext ¶ added in v1.25.0
func FromStatus ¶ added in v1.21.0
FromStatus converts gRPC Status to service error.
func GetMetricsHandlerFromContext ¶ added in v1.19.0
func GetNamespaceName ¶ added in v1.20.0
func MustGetNamespaceName ¶ added in v1.20.0
MustGetNamespaceName returns request namespace name or EmptyName if there's error when retrieving namespace name, e.g. unable to find namespace
func PopulateCallerInfo ¶ added in v1.25.0
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 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) Intercept ¶ added in v1.22.0
func (ni *ConcurrentRequestLimitInterceptor) Intercept( ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error)
type DCRedirectionPolicy ¶ added in v1.25.0
type DCRedirectionPolicy interface { WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, call func(string) error) error WithNamespaceRedirect(ctx context.Context, namespace namespace.Name, apiName string, call func(string) error) error }
DCRedirectionPolicy is a DC redirection policy interface
func RedirectionPolicyGenerator ¶ added in v1.25.0
func RedirectionPolicyGenerator(clusterMetadata cluster.Metadata, enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter, namespaceRegistry namespace.Registry, policy config.DCRedirectionPolicy) DCRedirectionPolicy
RedirectionPolicyGenerator generate corresponding redirection policy
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 MaskInternalErrorDetailsInterceptor ¶ added in v1.25.0
type MaskInternalErrorDetailsInterceptor struct {
// contains filtered or unexported fields
}
func NewMaskInternalErrorDetailsInterceptor ¶ added in v1.25.0
func NewMaskInternalErrorDetailsInterceptor( maskErrorSetting dynamicconfig.BoolPropertyFnWithNamespaceFilter, namespaceRegistry namespace.Registry, ) *MaskInternalErrorDetailsInterceptor
func (*MaskInternalErrorDetailsInterceptor) Intercept ¶ added in v1.25.0
func (i *MaskInternalErrorDetailsInterceptor) Intercept( ctx context.Context, req interface{}, _ *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (interface{}, error)
type MockDCRedirectionPolicy ¶ added in v1.25.0
type MockDCRedirectionPolicy struct {
// contains filtered or unexported fields
}
MockDCRedirectionPolicy is a mock of DCRedirectionPolicy interface.
func NewMockDCRedirectionPolicy ¶ added in v1.25.0
func NewMockDCRedirectionPolicy(ctrl *gomock.Controller) *MockDCRedirectionPolicy
NewMockDCRedirectionPolicy creates a new mock instance.
func (*MockDCRedirectionPolicy) EXPECT ¶ added in v1.25.0
func (m *MockDCRedirectionPolicy) EXPECT() *MockDCRedirectionPolicyMockRecorder
EXPECT returns an object that allows the caller to indicate expected use.
type MockDCRedirectionPolicyMockRecorder ¶ added in v1.25.0
type MockDCRedirectionPolicyMockRecorder struct {
// contains filtered or unexported fields
}
MockDCRedirectionPolicyMockRecorder is the mock recorder for MockDCRedirectionPolicy.
func (*MockDCRedirectionPolicyMockRecorder) WithNamespaceIDRedirect ¶ added in v1.25.0
func (mr *MockDCRedirectionPolicyMockRecorder) WithNamespaceIDRedirect(ctx, namespaceID, apiName, call any) *gomock.Call
WithNamespaceIDRedirect indicates an expected call of WithNamespaceIDRedirect.
func (*MockDCRedirectionPolicyMockRecorder) WithNamespaceRedirect ¶ added in v1.25.0
func (mr *MockDCRedirectionPolicyMockRecorder) WithNamespaceRedirect(ctx, namespace, apiName, call any) *gomock.Call
WithNamespaceRedirect indicates an expected call of WithNamespaceRedirect.
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 NoopRedirectionPolicy ¶ added in v1.25.0
type NoopRedirectionPolicy struct {
// contains filtered or unexported fields
}
NoopRedirectionPolicy is DC redirection policy which does nothing
func NewNoopRedirectionPolicy ¶ added in v1.25.0
func NewNoopRedirectionPolicy(currentClusterName string) *NoopRedirectionPolicy
NewNoopRedirectionPolicy is DC redirection policy which does nothing
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 Redirection ¶ added in v1.25.0
type Redirection struct {
// contains filtered or unexported fields
}
Redirection is simple wrapper over frontend service, doing redirection based on policy
func NewRedirection ¶ added in v1.25.0
func NewRedirection( enabledForNS 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) BeforeCall ¶ added in v1.25.0
func (*Redirection) Intercept ¶ added in v1.25.0
func (i *Redirection) Intercept( ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (_ any, retError error)
func (*Redirection) RedirectionAllowed ¶ added in v1.25.0
func (i *Redirection) RedirectionAllowed( ctx context.Context, ) bool
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
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 SelectedAPIsForwardingRedirectionPolicy ¶ added in v1.25.0
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 ¶ added in v1.25.0
func NewAllAPIsForwardingPolicy(currentClusterName string, enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter, namespaceRegistry namespace.Registry) *SelectedAPIsForwardingRedirectionPolicy
NewAllAPIsForwardingPolicy creates a forwarding policy for all APIs based on namespace
func NewSelectedAPIsForwardingPolicy ¶ added in v1.25.0
func NewSelectedAPIsForwardingPolicy(currentClusterName string, enabledForNS dynamicconfig.BoolPropertyFnWithNamespaceFilter, namespaceRegistry namespace.Registry) *SelectedAPIsForwardingRedirectionPolicy
NewSelectedAPIsForwardingPolicy creates a forwarding policy for selected APIs based on namespace
func (*SelectedAPIsForwardingRedirectionPolicy) WithNamespaceIDRedirect ¶ added in v1.25.0
func (policy *SelectedAPIsForwardingRedirectionPolicy) WithNamespaceIDRedirect(ctx context.Context, namespaceID namespace.ID, apiName string, call func(string) error) error
WithNamespaceIDRedirect redirect the API call based on namespace ID
func (*SelectedAPIsForwardingRedirectionPolicy) WithNamespaceRedirect ¶ added in v1.25.0
func (policy *SelectedAPIsForwardingRedirectionPolicy) WithNamespaceRedirect(ctx context.Context, namespace namespace.Name, apiName string, call func(string) error) error
WithNamespaceRedirect redirect the API call based on namespace name
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, logAllReqErrors dynamicconfig.BoolPropertyFnWithNamespaceFilter, ) *TelemetryInterceptor
func (*TelemetryInterceptor) HandleError ¶ added in v1.25.0
func (*TelemetryInterceptor) RecordLatencyMetrics ¶ added in v1.25.0
func (*TelemetryInterceptor) StreamIntercept ¶ added in v1.21.0
func (ti *TelemetryInterceptor) StreamIntercept( service any, 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 any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler, ) (any, error)