Skip to content

Implement new task queue kind to send worker commands#9899

Open
rkannan82 wants to merge 18 commits intomainfrom
kannan/worker-commands-partition-metrics
Open

Implement new task queue kind to send worker commands#9899
rkannan82 wants to merge 18 commits intomainfrom
kannan/worker-commands-partition-metrics

Conversation

@rkannan82
Copy link
Copy Markdown
Contributor

@rkannan82 rkannan82 commented Apr 10, 2026

What

Add support for TASK_QUEUE_KIND_WORKER_COMMANDS in the matching service. This is a new task queue kind for server-to-worker communication (e.g. activity cancellations), represented by a new WorkerCommandsPartition type in the tqid package — analogous to how StickyPartition represents sticky queues.

Also adds a distinct partition metric tag for worker-commands queues so their traffic can be distinguished from user-facing normal queues in metrics.

Depends on #9900.

Why

Worker_Commands queue kind has different properties compared to a normal user defined queue.
We also want to distinguish metrics for internally created queues from user-facing normal queues.

How did you test it?

Unit tests covering metric tag generation for normal, sticky, and worker-commands partitions.

🤖 Generated with Claude Code

@rkannan82 rkannan82 requested review from a team as code owners April 10, 2026 00:59
@rkannan82 rkannan82 changed the title Add WorkerCommandsPartition type for metrics Add WorkerCommandsPartition type for worker-commands task queues Apr 10, 2026
@rkannan82 rkannan82 changed the title Add WorkerCommandsPartition type for worker-commands task queues Add TASK_QUEUE_KIND_WORKER_COMMANDS support Apr 10, 2026
Replace Kind() == STICKY checks with IsEphemeral() where the behavior
applies to all ephemeral partition types (sticky, and future types like
worker-commands), not just sticky queues specifically.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from 6fd76ef to 872065b Compare April 10, 2026 04:02
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch 5 times, most recently from 7d9ffcf to a51f55b Compare April 10, 2026 04:25
@rkannan82 rkannan82 changed the base branch from main to kannan/ephemeral-partition-property April 10, 2026 04:26
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch from a163283 to 2b99d6a Compare April 10, 2026 04:54
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from a51f55b to d3d045d Compare April 10, 2026 04:54
…ants

These are used in IsEphemeral() code paths that apply to all ephemeral
partition types, not just sticky queues.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch from 2b99d6a to 8e2ff4f Compare April 10, 2026 17:22
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from d3d045d to 6a515ee Compare April 10, 2026 17:22
@rkannan82 rkannan82 changed the title Add TASK_QUEUE_KIND_WORKER_COMMANDS support Implement new task queue kind to send worker commands Apr 12, 2026
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch 2 times, most recently from 81d28e9 to fb145ab Compare April 14, 2026 17:20
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch 2 times, most recently from a1a9cca to 994395c Compare April 14, 2026 22:49
Replace the single IsEphemeral() method on the Partition interface with
four specific property methods: HasTTLExpiry(), SupportsFairness(),
SupportsVersioning(), and SupportsPartitions(). Each call site now uses
the property that governs its behavior, making it clearer why a check
exists and easier to set correct values for new partition types.

PartitionCount() returns 1 when SupportsPartitions() is false, enforcing
the single-partition constraint explicitly.

Describe task queue checks use Kind() == NORMAL since only user-facing
queues can be described — this is about the queue's visibility, not a
specific property.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/ephemeral-partition-property branch from 994395c to 2a7094c Compare April 14, 2026 22:53
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from fb145ab to 5f7413c Compare April 14, 2026 23:00
@rkannan82 rkannan82 requested review from ShahabT and dnr April 15, 2026 00:52
Comment thread common/metrics/task_queues.go Outdated
rkannan82 and others added 7 commits April 14, 2026 19:46
…k for load-on-demand

Replace HasTTLExpiry() bool with PersistenceTTL() time.Duration so partition
types own their TTL values. Use explicit Kind() != STICKY check for the
load-on-demand decision since that is specific to sticky queue semantics,
not a general property of partitions with TTL.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move partition metric label from type assertions in metrics helpers to
the Partition interface, so each partition kind defines its own label.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When the SDK sets Kind=TASK_QUEUE_KIND_WORKER_COMMANDS, the server now
creates a WorkerCommandsPartition (similar to StickyPartition). Metrics
for these partitions get partition=__worker_commands__ and the taskqueue
tag is suppressed to __omitted__ to prevent cardinality explosion from
per-worker queue names.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update API dep to include TASK_QUEUE_KIND_WORKER_COMMANDS enum.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 force-pushed the kannan/worker-commands-partition-metrics branch from 37523af to a57d54a Compare April 15, 2026 04:50
@rkannan82 rkannan82 requested a review from dnr April 15, 2026 05:28
rkannan82 and others added 2 commits April 14, 2026 22:28
The existing metrics framework already handles task queue name
cardinality via the taskQueueBreakdown parameter. Also add staticcheck
to nolint directives for NamespaceId and RpcName methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Regenerate proto import map to include the callback/v1 proto added in
the API dependency bump.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread common/tqid/task_queue_id.go Outdated
Comment thread common/tqid/task_queue_id.go
Base automatically changed from kannan/ephemeral-partition-property to main April 15, 2026 21:16
rkannan82 and others added 4 commits April 15, 2026 14:29
The name field was always identical to taskQueue.Name() since
worker-commands queues have no separate identity like sticky queues do.
Add tests for PartitionFromProto with WORKER_COMMANDS kind and for
partition property methods.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…s-partition-metrics

# Conflicts:
#	common/metrics/task_queues.go
#	common/tqid/task_queue_id.go
#	go.mod
#	go.sum
#	service/matching/db.go
#	service/matching/matching_engine.go
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 enabled auto-merge (squash) April 15, 2026 22:28
@rkannan82 rkannan82 disabled auto-merge April 15, 2026 22:29
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rkannan82 rkannan82 requested a review from ShahabT April 16, 2026 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants