Skip to content

Commit 4ad99d9

Browse files
durable-workflow.github.io: update v2 changes
1 parent 6c0f639 commit 4ad99d9

File tree

2 files changed

+56
-4
lines changed

2 files changed

+56
-4
lines changed

docs/configuration/microservices.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,9 @@ POST /webhooks/activity-attempts/{attemptId}/complete
283283
POST /webhooks/activity-attempts/{attemptId}/fail
284284
```
285285

286-
The poll route accepts optional `connection`, `queue`, `limit` (1–100, default 10), and `compatibility` query parameters. It returns the same task summary list as the PHP `poll()` method, wrapped in a `{"tasks": [...]}` envelope. A standalone server uses this route to discover ready activity tasks before claiming them by id.
286+
The poll route accepts optional `connection`, `queue`, `limit` (1–100, default 10), `compatibility`, and `namespace` query parameters. It returns the same task summary list as the PHP `poll()` method, wrapped in a `{"tasks": [...]}` envelope. A standalone server uses this route to discover ready activity tasks before claiming them by id.
287287

288-
That HTTP surface is still the same first bridge, not a complete hosted cross-language worker service. It does not yet provide long-poll claim loops, namespaces, or service-level routing. External workers should integrate through durable task ids, execution ids, attempt ids, codec-tagged payloads, heartbeats, completion or failure records, and late-result handling. They should not depend on mirroring placeholder PHP classes or sharing queue-serialized PHP payloads as the protocol boundary.
288+
That HTTP surface is still the same first bridge, not a complete hosted cross-language worker service. It does not yet provide long-poll claim loops or service-level routing. Namespace scoping is supported at the package level through `poll()` and visibility filters; the HTTP poll routes accept a `namespace` query parameter. External workers should integrate through durable task ids, execution ids, attempt ids, codec-tagged payloads, heartbeats, completion or failure records, and late-result handling. They should not depend on mirroring placeholder PHP classes or sharing queue-serialized PHP payloads as the protocol boundary.
289289

290290
## Workflow Task Boundary
291291

@@ -463,7 +463,7 @@ Serialized values (`result`, `arguments`) should match the run's `payload_codec`
463463

464464
The default implementation is `Workflow\V2\Support\DefaultWorkflowTaskBridge`. Apps that need custom claim, lease, or execution behavior can bind their own implementation of `Workflow\V2\Contracts\WorkflowTaskBridge` in the container.
465465

466-
The workflow task bridge uses the same backend/compatibility checks, task lease semantics, and summary projection as the default `RunWorkflowTask` queue job. It does not yet provide long-poll discovery or namespace routing.
466+
The workflow task bridge uses the same backend/compatibility checks, task lease semantics, and summary projection as the default `RunWorkflowTask` queue job. It supports namespace filtering through the `namespace` parameter on `poll()`. It does not yet provide long-poll discovery.
467467

468468
### HTTP routes
469469

@@ -479,7 +479,7 @@ POST /webhooks/workflow-tasks/{taskId}/fail
479479
POST /webhooks/workflow-tasks/{taskId}/heartbeat
480480
```
481481

482-
**Poll** discovers ready workflow tasks. Accepts optional `connection`, `queue`, `limit` (1–100, default 10), and `compatibility` query parameters. Returns `{"tasks": [...]}` with the same task summary shape as the PHP `poll()` method.
482+
**Poll** discovers ready workflow tasks. Accepts optional `connection`, `queue`, `limit` (1–100, default 10), `compatibility`, and `namespace` query parameters. Returns `{"tasks": [...]}` with the same task summary shape as the PHP `poll()` method.
483483

484484
**Claim** creates a lease on a ready workflow task. Pass an optional `lease_owner` string in the request body. Returns the claim payload on success or a rejection reason on failure:
485485

@@ -564,6 +564,7 @@ Options:
564564
- `arguments` — codec-tagged serialized arguments (string)
565565
- `connection` — queue connection override
566566
- `queue` — queue name override
567+
- `namespace` — execution namespace for multi-namespace isolation (falls back to `WORKFLOW_V2_NAMESPACE` config)
567568
- `business_key` — caller-supplied business key
568569
- `labels` — visibility labels for fleet search
569570
- `memo` — non-indexed metadata
@@ -668,6 +669,7 @@ if ($result['found']) {
668669
// Instance metadata
669670
$result['workflow_instance_id']; // 'order-12345'
670671
$result['workflow_type']; // 'order-processing'
672+
$result['namespace']; // 'production' or null
671673
$result['business_key']; // 'order-12345'
672674
$result['run_count']; // 1
673675

docs/configuration/options.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,56 @@ The `$timeout` setting is used to control the maximum number of seconds an activ
7171

7272
The `backoff` method returns an array of integers corresponding to the current attempt. The default `backoff` method decays exponentially to 2 minutes. This can be overridden by implementing the `backoff` method on the activity class.
7373

74+
## Namespace
75+
76+
Workflows can be scoped to a namespace for multi-namespace isolation. When a namespace is configured, it is persisted on every workflow instance, run, task, and run-summary projection created through the control plane. Task bridge polling and Waterline visibility filters can then restrict results to a single namespace.
77+
78+
Set the default namespace via environment variable:
79+
80+
```env
81+
WORKFLOW_V2_NAMESPACE=production
82+
```
83+
84+
Or in `config/workflows.php`:
85+
86+
```php
87+
'v2' => [
88+
'namespace' => env('WORKFLOW_V2_NAMESPACE'),
89+
// ...
90+
],
91+
```
92+
93+
The control plane also accepts a per-call namespace override in the `start()` options:
94+
95+
```php
96+
$controlPlane->start('order-processing', 'order-12345', [
97+
'namespace' => 'staging',
98+
// ...
99+
]);
100+
```
101+
102+
When no namespace is configured and none is passed explicitly, instances have a `null` namespace and are visible to all consumers.
103+
104+
### Waterline namespace scoping
105+
106+
When Waterline is deployed against a shared database with multiple namespaces, set `WATERLINE_NAMESPACE` to restrict all list views to one namespace:
107+
108+
```env
109+
WATERLINE_NAMESPACE=production
110+
```
111+
112+
This injects a namespace filter into every visibility query so Waterline only shows workflows belonging to the configured namespace.
113+
114+
### Task bridge namespace filtering
115+
116+
Both the workflow and activity task bridges accept an optional `namespace` parameter on `poll()`:
117+
118+
```php
119+
$tasks = $bridge->poll('redis', 'default', limit: 10, namespace: 'production');
120+
```
121+
122+
When omitted, `poll()` returns tasks from all namespaces (backward-compatible with pre-namespace installations).
123+
74124
## Durable Type Aliases
75125

76126
Durable type keys for workflows and activities are stored when you register them under `workflows.v2.types`. Failure payloads can use the same pattern for exception classes:

0 commit comments

Comments
 (0)