Skip to content

Commit e2d633f

Browse files
Revert "Use workflow bridge filters for typed worker polling"
This reverts commit cc59c48.
1 parent cc59c48 commit e2d633f

2 files changed

Lines changed: 41 additions & 40 deletions

File tree

app/Support/WorkflowTaskPoller.php

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ private function claimReadyTask(
430430
limit: $limit,
431431
compatibility: null,
432432
namespace: $namespace,
433-
workflowTypes: $supportedWorkflowTypes,
434433
);
435434

436435
\Log::info('[WorkflowTaskPoller] claimReadyTask called', [
@@ -483,6 +482,16 @@ private function claimReadyTask(
483482
continue;
484483
}
485484

485+
if (! $this->matchesWorkflowType($supportedWorkflowTypes, $readyTask['workflow_type'] ?? null)) {
486+
\Log::debug('[WorkflowTaskPoller] Skipping task: workflow type not supported', [
487+
'taskId' => $readyTask['task_id'] ?? null,
488+
'taskWorkflowType' => $readyTask['workflow_type'] ?? null,
489+
'supportedWorkflowTypes' => $supportedWorkflowTypes,
490+
]);
491+
492+
continue;
493+
}
494+
486495
$taskId = is_string($readyTask['task_id'] ?? null)
487496
? $readyTask['task_id']
488497
: null;
@@ -611,6 +620,34 @@ private function matchesCompatibility(?string $buildId, mixed $compatibility): b
611620
return $buildId !== null && $compatibility === $buildId;
612621
}
613622

623+
/**
624+
* @param list<string> $supportedTypes
625+
*/
626+
/**
627+
* Check if a task's workflow type matches the worker's supported types.
628+
*
629+
* - If worker supports all types (empty list), match any task
630+
* - If worker supports specific types, only match tasks with those types
631+
* - Tasks with missing/empty workflow_type only match "all types" workers
632+
*
633+
* @param list<string> $supportedTypes
634+
*/
635+
private function matchesWorkflowType(array $supportedTypes, mixed $workflowType): bool
636+
{
637+
// Worker supports all workflow types
638+
if ($supportedTypes === []) {
639+
return true;
640+
}
641+
642+
// Task has no workflow type - only matches workers that accept all types
643+
if (! is_string($workflowType) || trim($workflowType) === '') {
644+
return false;
645+
}
646+
647+
// Check if task's workflow type is in worker's supported list
648+
return in_array($workflowType, $supportedTypes, true);
649+
}
650+
614651
private function nextVisibleReadyAt(string $namespace, string $taskQueue, ?string $buildId): ?\DateTimeInterface
615652
{
616653
$query = NamespaceWorkflowScope::taskQuery($namespace)

tests/Feature/WorkflowWorkerProtocolTest.php

Lines changed: 3 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ public function test_it_uses_a_server_local_lease_counter_for_workflow_task_atte
578578
): void {
579579
$mock->shouldReceive('poll')
580580
->times(2)
581-
->with(null, 'external-workflows', 10, null, 'default', [])
581+
->with(null, 'external-workflows', 10, null, 'default')
582582
->andReturn(
583583
[[
584584
'task_id' => $task->id,
@@ -1390,7 +1390,7 @@ public function test_it_drops_claimed_workflow_tasks_when_the_bridge_cannot_buil
13901390
$this->mock(WorkflowTaskBridge::class, function (MockInterface $mock) use ($recordedAt): void {
13911391
$mock->shouldReceive('poll')
13921392
->once()
1393-
->with(null, 'external-workflows', 10, null, 'default', [])
1393+
->with(null, 'external-workflows', 10, null, 'default')
13941394
->andReturn([
13951395
[
13961396
'task_id' => 'wf-task-missing-row',
@@ -1461,7 +1461,7 @@ public function test_it_does_not_fall_back_to_a_local_ready_scan_when_the_workfl
14611461
$this->mock(WorkflowTaskBridge::class, function (MockInterface $mock): void {
14621462
$mock->shouldReceive('poll')
14631463
->once()
1464-
->with(null, 'external-workflows', 10, null, 'default', [])
1464+
->with(null, 'external-workflows', 10, null, 'default')
14651465
->andReturn([]);
14661466
});
14671467

@@ -1476,42 +1476,6 @@ public function test_it_does_not_fall_back_to_a_local_ready_scan_when_the_workfl
14761476
->assertJsonPath('task', null);
14771477
}
14781478

1479-
public function test_it_passes_supported_workflow_types_to_the_workflow_bridge_poll(): void
1480-
{
1481-
Queue::fake();
1482-
1483-
$this->configureWorkflowTypes();
1484-
$this->createNamespace('default', 'Default namespace');
1485-
1486-
$this->mock(WorkflowTaskBridge::class, function (MockInterface $mock): void {
1487-
$mock->shouldReceive('poll')
1488-
->once()
1489-
->with(
1490-
null,
1491-
'external-workflows',
1492-
10,
1493-
null,
1494-
'default',
1495-
['tests.external-greeting-workflow'],
1496-
)
1497-
->andReturn([]);
1498-
});
1499-
1500-
$this->registerWorker(
1501-
'php-worker-typed-bridge',
1502-
'external-workflows',
1503-
supportedWorkflowTypes: ['tests.external-greeting-workflow'],
1504-
);
1505-
1506-
$this->withHeaders($this->workerHeaders())
1507-
->postJson('/api/worker/workflow-tasks/poll', [
1508-
'worker_id' => 'php-worker-typed-bridge',
1509-
'task_queue' => 'external-workflows',
1510-
])
1511-
->assertOk()
1512-
->assertJsonPath('task', null);
1513-
}
1514-
15151479
public function test_it_passes_the_next_visible_workflow_task_deadline_into_long_polling(): void
15161480
{
15171481
Queue::fake();

0 commit comments

Comments
 (0)