Skip to content

Commit 178607e

Browse files
durable-workflow.github.io: update v2 changes
1 parent 187d06a commit 178607e

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

docs/configuration/options.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,34 @@ When Waterline is deployed against a shared database with multiple namespaces, s
109109
WATERLINE_NAMESPACE=production
110110
```
111111

112-
This injects a namespace filter into every visibility query so Waterline only shows workflows belonging to the configured namespace.
112+
This injects a namespace filter into every visibility query so Waterline only shows workflows belonging to the configured namespace. When set, Waterline also scopes all command operations (cancel, signal, terminate, update, repair, archive, and queries) to the configured namespace — a command targeting an instance or run that belongs to a different namespace will return a 404 instead of executing.
113+
114+
### Command namespace scoping
115+
116+
`WorkflowStub::load()`, `loadSelection()`, and `loadRun()` accept an optional `namespace` parameter:
117+
118+
```php
119+
use Workflow\V2\WorkflowStub;
120+
121+
// Load only if the instance belongs to the given namespace
122+
$stub = WorkflowStub::load('order-12345', namespace: 'production');
123+
124+
// Load a specific run, scoped to namespace
125+
$stub = WorkflowStub::loadRun($runId, namespace: 'production');
126+
127+
// Load a specific selection, scoped to namespace
128+
$stub = WorkflowStub::loadSelection('order-12345', $runId, namespace: 'production');
129+
```
130+
131+
When `namespace` is `null` (the default), loading is unscoped and works against all namespaces — this preserves backward compatibility. When a namespace is provided, the query filters by namespace at the database level and throws `ModelNotFoundException` if the workflow does not exist in that namespace.
132+
133+
The control plane command methods (`signal`, `cancel`, `terminate`, `update`, `repair`, `archive`) also accept `namespace` in their options array:
134+
135+
```php
136+
$controlPlane->cancel('order-12345', [
137+
'namespace' => 'production',
138+
]);
139+
```
113140

114141
### Task bridge namespace filtering
115142

docs/defining-workflows/workflow-id.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ $sameSelectedRun = WorkflowStub::loadRun($runId);
4040

4141
That instance-scoped selector is useful when another system already stored the public instance id and later wants to pin a historical run without changing the outer workflow address.
4242

43+
All three loaders accept an optional `namespace` parameter. When provided, loading is scoped to the given namespace at the query level — a workflow belonging to a different namespace will not be found. See [Namespace Scoping](/configuration/options#namespace-scoping) for details.
44+
4345
Instance-scoped current-run selection no longer trusts only the mutable `workflow_instances.current_run_id` pointer. `load($instanceId)`, `currentRunId()`, Waterline instance routes, and other instance-targeted current-run actions resolve the newest durable run in the instance chain, so continue-as-new navigation still lands on the right run even if that pointer is temporarily stale or null.
4446

4547
That same distinction applies to query methods:

0 commit comments

Comments
 (0)