matching

package
v1.17.3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2022 License: MIT Imports: 60 Imported by: 0

Documentation

Overview

Package matching is a generated GoMock package.

Package matching is a generated GoMock package.

Package matching is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoTasks is exported temporarily for integration test
	ErrNoTasks = errors.New("no tasks")
)

Functions

func HashVersioningData added in v1.17.3

func HashVersioningData(data *persistence.VersioningData) []byte

HashVersioningData returns a farm.Fingerprint64 hash of the versioning data as bytes. If the data is nonexistent or invalid, returns nil.

func PersistenceRateLimitingParamsProvider added in v1.17.2

func PersistenceRateLimitingParamsProvider(
	serviceConfig *Config,
) service.PersistenceRateLimitingParams

This function is the same between services but uses different config sources. if-case comes from resourceImpl.New.

func RateLimitInterceptorProvider added in v1.13.0

func RateLimitInterceptorProvider(
	serviceConfig *Config,
) *interceptor.RateLimitInterceptor

func RetryableInterceptorProvider added in v1.17.3

func RetryableInterceptorProvider() *interceptor.RetryableInterceptor

func ServiceLifetimeHooks added in v1.13.0

func ServiceLifetimeHooks(
	lc fx.Lifecycle,
	svcStoppedCh chan struct{},
	svc *Service,
)

func ServiceResolverProvider added in v1.14.0

func ServiceResolverProvider(membershipMonitor membership.Monitor) (membership.ServiceResolver, error)

func TelemetryInterceptorProvider added in v1.13.0

func TelemetryInterceptorProvider(
	logger log.Logger,
	namespaceRegistry namespace.Registry,
	metricsClient metrics.Client,
) *interceptor.TelemetryInterceptor

func ThrottledLoggerRpsFnProvider added in v1.13.0

func ThrottledLoggerRpsFnProvider(serviceConfig *Config) resource.ThrottledLoggerRpsFn

func ToBuildIdOrderingResponse added in v1.17.3

func ToBuildIdOrderingResponse(g *persistence.VersioningData, maxDepth int) *workflowservice.GetWorkerBuildIdOrderingResponse

func UpdateVersionsGraph added in v1.17.3

func UpdateVersionsGraph(existingData *persistence.VersioningData, req *workflowservice.UpdateWorkerBuildIdOrderingRequest, maxSize int) error

Given an existing graph and an update request, update the graph appropriately.

See the API docs for more detail. In short, the graph looks like one long line of default versions, each of which is incompatible with the previous, optionally with branching compatibility branches. Like so:

─┬─1.0───2.0─┬─3.0───4.0

│           ├─3.1
│           └─3.2
├─1.1
├─1.2
└─1.3

In the above graph, 4.0 is the current default, and [1.3, 3.2] is the set of current compatible leaves. Links going left are incompatible relationships, and links going up are compatible relationships.

A request may:

  1. Add a new version to the graph, as a default version
  2. Add a new version to the graph, compatible with some existing version.
  3. Add a new version to the graph, compatible with some existing version and as the new default.
  4. Unset a version as a default. It will be dropped and its previous incompatible version becomes default.
  5. Unset a version as a compatible. It will be dropped and its previous compatible version will become the new compatible leaf for that branch.

Types

type Config added in v0.3.0

type Config struct {
	PersistenceMaxQPS                     dynamicconfig.IntPropertyFn
	PersistenceGlobalMaxQPS               dynamicconfig.IntPropertyFn
	PersistenceNamespaceMaxQPS            dynamicconfig.IntPropertyFnWithNamespaceFilter
	EnablePersistencePriorityRateLimiting dynamicconfig.BoolPropertyFn
	SyncMatchWaitDuration                 dynamicconfig.DurationPropertyFnWithTaskQueueInfoFilters
	RPS                                   dynamicconfig.IntPropertyFn
	ShutdownDrainDuration                 dynamicconfig.DurationPropertyFn

	RangeSize                    int64
	GetTasksBatchSize            dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	UpdateAckInterval            dynamicconfig.DurationPropertyFnWithTaskQueueInfoFilters
	IdleTaskqueueCheckInterval   dynamicconfig.DurationPropertyFnWithTaskQueueInfoFilters
	MaxTaskqueueIdleTime         dynamicconfig.DurationPropertyFnWithTaskQueueInfoFilters
	NumTaskqueueWritePartitions  dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	NumTaskqueueReadPartitions   dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	ForwarderMaxOutstandingPolls dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	ForwarderMaxOutstandingTasks dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	ForwarderMaxRatePerSecond    dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	ForwarderMaxChildrenPerNode  dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	MaxVersionGraphSize          dynamicconfig.IntPropertyFn
	MetadataPollFrequency        dynamicconfig.DurationPropertyFn

	// Time to hold a poll request before returning an empty response if there are no tasks
	LongPollExpirationInterval dynamicconfig.DurationPropertyFnWithTaskQueueInfoFilters
	MinTaskThrottlingBurstSize dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	MaxTaskDeleteBatchSize     dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters

	// taskWriter configuration
	OutstandingTaskAppendsThreshold dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters
	MaxTaskBatchSize                dynamicconfig.IntPropertyFnWithTaskQueueInfoFilters

	ThrottledLogRPS dynamicconfig.IntPropertyFn

	AdminNamespaceToPartitionDispatchRate          dynamicconfig.FloatPropertyFnWithNamespaceFilter
	AdminNamespaceTaskqueueToPartitionDispatchRate dynamicconfig.FloatPropertyFnWithTaskQueueInfoFilters
}

Config represents configuration for matching service

func NewConfig added in v0.3.0

func NewConfig(dc *dynamicconfig.Collection) *Config

NewConfig returns new service config with default values

type Engine

type Engine interface {
	Stop()
	AddWorkflowTask(hCtx *handlerContext, addRequest *matchingservice.AddWorkflowTaskRequest) (syncMatch bool, err error)
	AddActivityTask(hCtx *handlerContext, addRequest *matchingservice.AddActivityTaskRequest) (syncMatch bool, err error)
	PollWorkflowTaskQueue(hCtx *handlerContext, request *matchingservice.PollWorkflowTaskQueueRequest) (*matchingservice.PollWorkflowTaskQueueResponse, error)
	PollActivityTaskQueue(hCtx *handlerContext, request *matchingservice.PollActivityTaskQueueRequest) (*matchingservice.PollActivityTaskQueueResponse, error)
	QueryWorkflow(hCtx *handlerContext, request *matchingservice.QueryWorkflowRequest) (*matchingservice.QueryWorkflowResponse, error)
	RespondQueryTaskCompleted(hCtx *handlerContext, request *matchingservice.RespondQueryTaskCompletedRequest) error
	CancelOutstandingPoll(hCtx *handlerContext, request *matchingservice.CancelOutstandingPollRequest) error
	DescribeTaskQueue(hCtx *handlerContext, request *matchingservice.DescribeTaskQueueRequest) (*matchingservice.DescribeTaskQueueResponse, error)
	ListTaskQueuePartitions(hCtx *handlerContext, request *matchingservice.ListTaskQueuePartitionsRequest) (*matchingservice.ListTaskQueuePartitionsResponse, error)
	UpdateWorkerBuildIdOrdering(ctx *handlerContext, request *matchingservice.UpdateWorkerBuildIdOrderingRequest) (*matchingservice.UpdateWorkerBuildIdOrderingResponse, error)
	GetWorkerBuildIdOrdering(ctx *handlerContext, request *matchingservice.GetWorkerBuildIdOrderingRequest) (*matchingservice.GetWorkerBuildIdOrderingResponse, error)
	InvalidateTaskQueueMetadata(ctx *handlerContext, request *matchingservice.InvalidateTaskQueueMetadataRequest) (*matchingservice.InvalidateTaskQueueMetadataResponse, error)
	GetTaskQueueMetadata(ctx *handlerContext, request *matchingservice.GetTaskQueueMetadataRequest) (*matchingservice.GetTaskQueueMetadataResponse, error)
}

Engine exposes interfaces for clients to interact with the matching engine

func NewEngine

func NewEngine(
	taskManager persistence.TaskManager,
	historyClient historyservice.HistoryServiceClient,
	matchingClient matchingservice.MatchingServiceClient,
	config *Config,
	logger log.Logger,
	metricsClient metrics.Client,
	namespaceRegistry namespace.Registry,
	resolver membership.ServiceResolver,
	clusterMeta cluster.Metadata,
) Engine

NewEngine creates an instance of matching engine

type Forwarder added in v0.7.0

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

Forwarder is the type that contains state pertaining to the api call forwarder component

func (*Forwarder) AddReqTokenC added in v0.7.0

func (fwdr *Forwarder) AddReqTokenC() <-chan *ForwarderReqToken

AddReqTokenC returns a channel that can be used to wait for a token that's necessary before making a ForwardTask or ForwardQueryTask API call. After the API call is invoked, token.release() must be invoked

func (*Forwarder) ForwardPoll added in v0.7.0

func (fwdr *Forwarder) ForwardPoll(ctx context.Context) (*internalTask, error)

ForwardPoll forwards a poll request to parent task queue partition if it exist

func (*Forwarder) ForwardQueryTask added in v0.7.0

func (fwdr *Forwarder) ForwardQueryTask(
	ctx context.Context,
	task *internalTask,
) (*matchingservice.QueryWorkflowResponse, error)

ForwardQueryTask forwards a query task to parent task queue partition, if it exist

func (*Forwarder) ForwardTask added in v0.7.0

func (fwdr *Forwarder) ForwardTask(ctx context.Context, task *internalTask) error

ForwardTask forwards an activity or workflow task to the parent task queue partition if it exist

func (*Forwarder) PollReqTokenC added in v0.7.0

func (fwdr *Forwarder) PollReqTokenC() <-chan *ForwarderReqToken

PollReqTokenC returns a channel that can be used to wait for a token that's necessary before making a ForwardPoll API call. After the API call is invoked, token.release() must be invoked

type ForwarderReqToken added in v0.7.0

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

ForwarderReqToken is the token that must be acquired before making forwarder API calls. This type contains the state for the token itself

type Handler

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

Handler - gRPC handler interface for matchingservice

func HandlerProvider added in v1.14.0

func HandlerProvider(
	config *Config,
	logger resource.SnTaggedLogger,
	throttledLogger resource.ThrottledLogger,
	taskManager persistence.TaskManager,
	historyClient historyservice.HistoryServiceClient,
	matchingRawClient resource.MatchingRawClient,
	matchingServiceResolver membership.ServiceResolver,
	metricsClient metrics.Client,
	namespaceRegistry namespace.Registry,
	clusterMetadata cluster.Metadata,
) *Handler

func NewHandler

func NewHandler(
	config *Config,
	logger log.Logger,
	throttledLogger log.Logger,
	taskManager persistence.TaskManager,
	historyClient historyservice.HistoryServiceClient,
	matchingRawClient matchingservice.MatchingServiceClient,
	matchingServiceResolver membership.ServiceResolver,
	metricsClient metrics.Client,
	namespaceRegistry namespace.Registry,
	clusterMetadata cluster.Metadata,
) *Handler

NewHandler creates a gRPC handler for the matchingservice

func (*Handler) AddActivityTask

func (h *Handler) AddActivityTask(
	ctx context.Context,
	request *matchingservice.AddActivityTaskRequest,
) (_ *matchingservice.AddActivityTaskResponse, retError error)

AddActivityTask - adds an activity task.

func (*Handler) AddWorkflowTask added in v0.27.0

func (h *Handler) AddWorkflowTask(
	ctx context.Context,
	request *matchingservice.AddWorkflowTaskRequest,
) (_ *matchingservice.AddWorkflowTaskResponse, retError error)

AddWorkflowTask - adds a workflow task.

func (*Handler) CancelOutstandingPoll added in v0.3.2

func (h *Handler) CancelOutstandingPoll(ctx context.Context,
	request *matchingservice.CancelOutstandingPollRequest) (_ *matchingservice.CancelOutstandingPollResponse, retError error)

CancelOutstandingPoll is used to cancel outstanding pollers

func (*Handler) DescribeTaskQueue added in v0.27.0

func (h *Handler) DescribeTaskQueue(
	ctx context.Context,
	request *matchingservice.DescribeTaskQueueRequest,
) (_ *matchingservice.DescribeTaskQueueResponse, retError error)

DescribeTaskQueue returns information about the target task queue, right now this API returns the pollers which polled this task queue in last few minutes. If includeTaskQueueStatus field is true, it will also return status of task queue's ackManager (readLevel, ackLevel, backlogCountHint and taskIDBlock).

func (*Handler) GetTaskQueueMetadata added in v1.17.3

func (h *Handler) GetTaskQueueMetadata(
	ctx context.Context,
	request *matchingservice.GetTaskQueueMetadataRequest,
) (_ *matchingservice.GetTaskQueueMetadataResponse, retError error)

func (*Handler) GetWorkerBuildIdOrdering added in v1.17.3

func (h *Handler) GetWorkerBuildIdOrdering(
	ctx context.Context,
	request *matchingservice.GetWorkerBuildIdOrderingRequest,
) (_ *matchingservice.GetWorkerBuildIdOrderingResponse, retError error)

GetWorkerBuildIdOrdering fetches the worker versioning graph for a task queue

func (*Handler) InvalidateTaskQueueMetadata added in v1.17.3

func (h *Handler) InvalidateTaskQueueMetadata(
	ctx context.Context,
	request *matchingservice.InvalidateTaskQueueMetadataRequest,
) (_ *matchingservice.InvalidateTaskQueueMetadataResponse, retError error)

InvalidateTaskQueueMetadata notifies a task queue that some data has changed, and should be invalidated/refreshed

func (*Handler) ListTaskQueuePartitions added in v0.27.0

func (h *Handler) ListTaskQueuePartitions(
	ctx context.Context,
	request *matchingservice.ListTaskQueuePartitionsRequest,
) (_ *matchingservice.ListTaskQueuePartitionsResponse, retError error)

ListTaskQueuePartitions returns information about partitions for a taskQueue

func (*Handler) PollActivityTaskQueue added in v0.27.0

func (h *Handler) PollActivityTaskQueue(
	ctx context.Context,
	request *matchingservice.PollActivityTaskQueueRequest,
) (_ *matchingservice.PollActivityTaskQueueResponse, retError error)

PollActivityTaskQueue - long poll for an activity task.

func (*Handler) PollWorkflowTaskQueue added in v0.27.0

func (h *Handler) PollWorkflowTaskQueue(
	ctx context.Context,
	request *matchingservice.PollWorkflowTaskQueueRequest,
) (_ *matchingservice.PollWorkflowTaskQueueResponse, retError error)

PollWorkflowTaskQueue - long poll for a workflow task.

func (*Handler) QueryWorkflow added in v0.3.2

func (h *Handler) QueryWorkflow(
	ctx context.Context,
	request *matchingservice.QueryWorkflowRequest,
) (_ *matchingservice.QueryWorkflowResponse, retError error)

QueryWorkflow queries a given workflow synchronously and return the query result.

func (*Handler) RespondQueryTaskCompleted added in v0.3.2

func (h *Handler) RespondQueryTaskCompleted(
	ctx context.Context,
	request *matchingservice.RespondQueryTaskCompletedRequest,
) (_ *matchingservice.RespondQueryTaskCompletedResponse, retError error)

RespondQueryTaskCompleted responds a query task completed

func (*Handler) Start

func (h *Handler) Start()

Start starts the handler

func (*Handler) Stop

func (h *Handler) Stop()

Stop stops the handler

func (*Handler) UpdateWorkerBuildIdOrdering added in v1.17.3

func (h *Handler) UpdateWorkerBuildIdOrdering(
	ctx context.Context,
	request *matchingservice.UpdateWorkerBuildIdOrderingRequest,
) (_ *matchingservice.UpdateWorkerBuildIdOrderingResponse, retError error)

UpdateWorkerBuildIdOrdering allows changing the worker versioning graph for a task queue

func (*Handler) Watch added in v0.27.0

type MockdbTaskQueueOwnership added in v1.15.0

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

MockdbTaskQueueOwnership is a mock of dbTaskQueueOwnership interface.

func NewMockdbTaskQueueOwnership added in v1.15.0

func NewMockdbTaskQueueOwnership(ctrl *gomock.Controller) *MockdbTaskQueueOwnership

NewMockdbTaskQueueOwnership creates a new mock instance.

func (*MockdbTaskQueueOwnership) EXPECT added in v1.15.0

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

type MockdbTaskQueueOwnershipMockRecorder added in v1.15.0

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

MockdbTaskQueueOwnershipMockRecorder is the mock recorder for MockdbTaskQueueOwnership.

type MockdbTaskReader added in v1.15.0

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

MockdbTaskReader is a mock of dbTaskReader interface.

func NewMockdbTaskReader added in v1.15.0

func NewMockdbTaskReader(ctrl *gomock.Controller) *MockdbTaskReader

NewMockdbTaskReader creates a new mock instance.

func (*MockdbTaskReader) EXPECT added in v1.15.0

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

type MockdbTaskReaderMockRecorder added in v1.15.0

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

MockdbTaskReaderMockRecorder is the mock recorder for MockdbTaskReader.

type MockdbTaskWriter added in v1.15.0

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

MockdbTaskWriter is a mock of dbTaskWriter interface.

func NewMockdbTaskWriter added in v1.15.0

func NewMockdbTaskWriter(ctrl *gomock.Controller) *MockdbTaskWriter

NewMockdbTaskWriter creates a new mock instance.

func (*MockdbTaskWriter) EXPECT added in v1.15.0

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

type MockdbTaskWriterMockRecorder added in v1.15.0

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

MockdbTaskWriterMockRecorder is the mock recorder for MockdbTaskWriter.

type QualifiedTaskQueueName added in v1.17.3

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

QualifiedTaskQueueName refers to the fully qualified task queue name

func NewTaskQueueNameWithPartition added in v1.17.3

func NewTaskQueueNameWithPartition(baseName string, partition int) (QualifiedTaskQueueName, error)

NewTaskQueueNameWithPartition can be used to create root and non-root taskqueue names easily without needing to manually craft the correct string. See newTaskQueueName for more details.

func (*QualifiedTaskQueueName) GetRoot added in v1.17.3

func (tn *QualifiedTaskQueueName) GetRoot() string

GetRoot returns the root name for a task queue

func (*QualifiedTaskQueueName) IsRoot added in v1.17.3

func (tn *QualifiedTaskQueueName) IsRoot() bool

IsRoot returns true if this task queue is a root partition

func (*QualifiedTaskQueueName) Parent added in v1.17.3

func (tn *QualifiedTaskQueueName) Parent(degree int) string

Parent returns the name of the parent task queue input:

degree: Number of children at each level of the tree

Returns empty string if this task queue is the root

func (*QualifiedTaskQueueName) String added in v1.17.3

func (tn *QualifiedTaskQueueName) String() string

type Service

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

Service represents the matching service

func NewService

func NewService(
	grpcServerOptions []grpc.ServerOption,
	serviceConfig *Config,
	logger resource.SnTaggedLogger,
	membershipMonitor membership.Monitor,
	grpcListener net.Listener,
	runtimeMetricsReporter *metrics.RuntimeMetricsReporter,
	handler *Handler,
	metricsHandler metrics.MetricsHandler,
	faultInjectionDataStoreFactory *client.FaultInjectionDataStoreFactory,
) *Service

func (*Service) GetFaultInjection added in v1.14.0

func (s *Service) GetFaultInjection() *client.FaultInjectionDataStoreFactory

func (*Service) Start

func (s *Service) Start()

Start starts the service

func (*Service) Stop

func (s *Service) Stop()

Stop stops the service

type TaskMatcher added in v0.6.0

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

TaskMatcher matches a task producer with a task consumer Producers are usually rpc calls from history or taskReader that drains backlog from db. Consumers are the task queue pollers

func (*TaskMatcher) MustOffer added in v0.6.0

func (tm *TaskMatcher) MustOffer(ctx context.Context, task *internalTask) error

MustOffer blocks until a consumer is found to handle this task Returns error only when context is canceled or the ratelimit is set to zero (allow nothing) The passed in context MUST NOT have a deadline associated with it

func (*TaskMatcher) Offer added in v0.6.0

func (tm *TaskMatcher) Offer(ctx context.Context, task *internalTask) (bool, error)

Offer offers a task to a potential consumer (poller) If the task is successfully matched with a consumer, this method will return true and no error. If the task is matched but consumer returned error, then this method will return true and error message. This method should not be used for query task. This method should ONLY be used for sync match.

When a local poller is not available and forwarding to a parent task queue partition is possible, this method will attempt forwarding to the parent partition.

Cases when this method will block:

Ratelimit: When a ratelimit token is not available, this method might block waiting for a token until the provided context timeout. Rate limits are not enforced for forwarded tasks from child partition.

Forwarded tasks that originated from db backlog: When this method is called with a task that is forwarded from a remote partition and if (1) this task queue is root (2) task was from db backlog - this method will block until context timeout trying to match with a poller. The caller is expected to set the correct context timeout.

returns error when:

  • ratelimit is exceeded (does not apply to query task)
  • context deadline is exceeded
  • task is matched and consumer returns error in response channel

func (*TaskMatcher) OfferQuery added in v0.7.0

func (tm *TaskMatcher) OfferQuery(ctx context.Context, task *internalTask) (*matchingservice.QueryWorkflowResponse, error)

OfferQuery will either match task to local poller or will forward query task. Local match is always attempted before forwarding is attempted. If local match occurs response and error are both nil, if forwarding occurs then response or error is returned.

func (*TaskMatcher) Poll added in v0.6.0

func (tm *TaskMatcher) Poll(ctx context.Context) (*internalTask, error)

Poll blocks until a task is found or context deadline is exceeded On success, the returned task could be a query task or a regular task Returns ErrNoTasks when context deadline is exceeded

func (*TaskMatcher) PollForQuery added in v0.6.0

func (tm *TaskMatcher) PollForQuery(ctx context.Context) (*internalTask, error)

PollForQuery blocks until a *query* task is found or context deadline is exceeded Returns ErrNoTasks when context deadline is exceeded

func (*TaskMatcher) Rate added in v0.6.0

func (tm *TaskMatcher) Rate() float64

Rate returns the current rate at which tasks are dispatched

func (*TaskMatcher) UpdateRatelimit added in v0.6.0

func (tm *TaskMatcher) UpdateRatelimit(rps *float64)

UpdateRatelimit updates the task dispatch rate

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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