tqid

package
v1.26.2-121.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoParent      = errors.New("root task queue partition has no parent")
	ErrInvalidDegree = errors.New("invalid task queue partition branching degree")
	ErrNonZeroSticky = errors.New("only sticky partitions can not have non-zero partition ID")
)

Functions

func NormalizeAndValidate added in v1.26.0

func NormalizeAndValidate(
	taskQueue *taskqueue.TaskQueue,
	defaultName string,
	maxIDLengthLimit int,
) error

NormalizeAndValidate validates a TaskQueue object and normalizes its fields. It checks the TaskQueue's name for emptiness, length, UTF-8 validity, and whitespace. For sticky queues, it also validates the NormalName. If the name is empty and defaultVal is provided, it sets the name to defaultVal. If the Kind is unspecified, it sets it to NORMAL.

Parameters:

  • taskQueue: The TaskQueue to validate and normalize. If nil, returns an error.
  • defaultName: Default name to use if taskQueue name is empty.
  • maxIDLengthLimit: Maximum allowed length for the TaskQueue name.

Returns an error if validation fails, nil otherwise.

func Validate added in v1.26.0

func Validate(taskQueueName string, maxLength int) error

Validate checks if a given task queue name is valid. It verifies the name is not empty, does not exceed the maximum length, and is a valid UTF-8 string.

Parameters:

  • name: The task queue name to validate.
  • maxLength: The maximum allowed length for the name.

Returns an error if the name is invalid, nil otherwise.

Types

type NormalPartition

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

NormalPartition is used to distribute load of a TaskQueue in multiple Matching instances. A normal partition is identified by `partitionId`. The partition with ID 0 is called a root partition.

func MustNormalPartitionFromRpcName added in v1.25.0

func MustNormalPartitionFromRpcName(rpcName string, namespaceId string, taskType enumspb.TaskQueueType) *NormalPartition

func NormalPartitionFromRpcName

func NormalPartitionFromRpcName(rpcName string, namespaceId string, taskType enumspb.TaskQueueType) (*NormalPartition, error)

func (*NormalPartition) IsRoot

func (p *NormalPartition) IsRoot() bool

func (*NormalPartition) Key

func (p *NormalPartition) Key() PartitionKey

func (*NormalPartition) Kind

func (*NormalPartition) NamespaceId

func (p *NormalPartition) NamespaceId() string

func (*NormalPartition) ParentPartition

func (p *NormalPartition) ParentPartition(degree int) (*NormalPartition, error)

ParentPartition returns a NormalPartition for the parent partition, using the given branching degree.

func (*NormalPartition) PartitionId

func (p *NormalPartition) PartitionId() int

func (*NormalPartition) RoutingKey

func (p *NormalPartition) RoutingKey() string

func (*NormalPartition) RpcName

func (p *NormalPartition) RpcName() string

func (*NormalPartition) TaskQueue

func (p *NormalPartition) TaskQueue() *TaskQueue

func (*NormalPartition) TaskType

func (p *NormalPartition) TaskType() enumspb.TaskQueueType

type Partition

type Partition interface {
	NamespaceId() string
	TaskQueue() *TaskQueue
	TaskType() enumspb.TaskQueueType
	// IsRoot always returns false for Sticky partitions
	IsRoot() bool
	Kind() enumspb.TaskQueueKind

	// RpcName returns the mangled name of the task queue partition, to be used in RPCs.
	//
	// RPC names look like this:
	//
	//  sticky partition:			<sticky name>
	//	root normal partition: 		<task queue name>
	//	non-root normal partition: 	/_sys/<task queue name>/<partition id>
	//
	// This scheme lets users use anything they like for a base name, except for strings
	// starting with "/_sys/", without ambiguity.
	//
	// For backward compatibility, unversioned low-level task queues with partition 0 do not
	// use mangled names, they use the bare base name.
	RpcName() string
	Key() PartitionKey
	// RoutingKey returns the string that should be used to find the owner of a task queue partition.
	RoutingKey() string
}

Partition is a sticky or normal partition of a TaskQueue. Each Partition has a distinct task queue partition manager in memory in Matching service. Normal partition with `partitionId=0` is called the "root". Sticky queues are not considered root.

func PartitionFromPartitionProto

func PartitionFromPartitionProto(proto *taskqueuespb.TaskQueuePartition, namespaceId string) Partition

func PartitionFromProto

func PartitionFromProto(proto *taskqueuepb.TaskQueue, namespaceId string, taskType enumspb.TaskQueueType) (Partition, error)

func UnsafePartitionFromProto added in v1.25.0

func UnsafePartitionFromProto(proto *taskqueuepb.TaskQueue, namespaceId string, taskType enumspb.TaskQueueType) Partition

UnsafePartitionFromProto tries parsing proto using PartitionFromProto but if it fails still returns a Partition object using the raw values in the proto. This method should only be used in logs/metrics, not in the server logic.

type PartitionKey

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

PartitionKey uniquely identifies a task queue partition, to be used in maps. Note that task queue kind (sticky vs normal) and normal name for sticky task queues are not part of the task queue partition identity.

type StickyPartition

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

StickyPartition is made by SDK for a single workflow worker to keep workflow tasks of the same execution in the same worker for caching benefits. Each sticky partition is identified by a unique `stickyName` generated by SDK. A StickyPartition can only have workflow task type.

func (*StickyPartition) IsRoot

func (s *StickyPartition) IsRoot() bool

func (*StickyPartition) Key

func (s *StickyPartition) Key() PartitionKey

func (*StickyPartition) Kind

func (*StickyPartition) NamespaceId

func (s *StickyPartition) NamespaceId() string

func (*StickyPartition) RootPartition

func (s *StickyPartition) RootPartition() Partition

func (*StickyPartition) RoutingKey

func (s *StickyPartition) RoutingKey() string

func (*StickyPartition) RpcName

func (s *StickyPartition) RpcName() string

func (*StickyPartition) StickyName

func (s *StickyPartition) StickyName() string

func (*StickyPartition) TaskQueue

func (s *StickyPartition) TaskQueue() *TaskQueue

func (*StickyPartition) TaskType

func (s *StickyPartition) TaskType() enumspb.TaskQueueType

type TaskQueue

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

TaskQueue represents a logical task queue for a type of tasks (e.g. Activity or Workflow). Under the hood, a TaskQueue can be broken down to multiple sticky or normal partitions.

func (*TaskQueue) Family

func (n *TaskQueue) Family() *TaskQueueFamily

func (*TaskQueue) Name

func (n *TaskQueue) Name() string

func (*TaskQueue) NamespaceId

func (n *TaskQueue) NamespaceId() string

func (*TaskQueue) NormalPartition

func (n *TaskQueue) NormalPartition(partitionId int) *NormalPartition

func (*TaskQueue) RootPartition

func (n *TaskQueue) RootPartition() *NormalPartition

func (*TaskQueue) StickyPartition

func (n *TaskQueue) StickyPartition(stickyName string) *StickyPartition

func (*TaskQueue) TaskType

func (n *TaskQueue) TaskType() enumspb.TaskQueueType

type TaskQueueFamily

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

TaskQueueFamily represents the high-level "task queue" that user creates by explicitly providing a task queue name when starting a worker or a workflow. A task queue family consists of separate TaskQueues for different types of task (e.g. Workflow, Activity).

func NewTaskQueueFamily

func NewTaskQueueFamily(namespaceId string, name string) (*TaskQueueFamily, error)

NewTaskQueueFamily takes a user-provided task queue name (aka family name) and returns a TaskQueueFamily. Returns an error if name looks like a mangled name.

func UnsafeTaskQueueFamily

func UnsafeTaskQueueFamily(namespaceId string, name string) *TaskQueueFamily

UnsafeTaskQueueFamily should be avoided as much as possible. Use NewTaskQueueFamily instead as it validates the tq name.

func (*TaskQueueFamily) Name

func (n *TaskQueueFamily) Name() string

func (*TaskQueueFamily) NamespaceId

func (n *TaskQueueFamily) NamespaceId() string

func (*TaskQueueFamily) TaskQueue

func (n *TaskQueueFamily) TaskQueue(taskType enumspb.TaskQueueType) *TaskQueue

Jump to

Keyboard shortcuts

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