You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/defining-workflows/starting-workflows.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -75,6 +75,46 @@ Visibility labels are exact-match strings for operator filtering in Waterline, n
75
75
76
76
`memo` is JSON-like metadata for selected-run detail and history export, not a list-filter or run-summary search field. Top-level and nested memo object keys must be non-empty strings up to 64 characters, and memo values may be scalars, `null`, arrays, or nested objects.
77
77
78
+
### Search Attributes
79
+
80
+
Search attributes are indexed scalar metadata for operator filtering and fleet visibility. Unlike memo, search attributes are surfaced in run list views and can be used for visibility filtering in Waterline:
81
+
82
+
```php
83
+
$workflow->start(
84
+
$orderId,
85
+
StartOptions::withVisibility(
86
+
businessKey: 'order-123',
87
+
labels: ['tenant' => 'acme'],
88
+
)->withSearchAttributes([
89
+
'priority' => 'high',
90
+
'status' => 'pending',
91
+
'amount' => '99.50',
92
+
]),
93
+
);
94
+
```
95
+
96
+
Search attribute keys follow the same rules as visibility label keys: letters, numbers, `.`, `_`, `-`, and `:`, up to 64 characters. Values must be scalars or `null`. Boolean values are cast to `"1"` or `"0"`, and `null` values are silently dropped. Empty string values after casting are also dropped.
97
+
98
+
Search attributes can be upserted during workflow execution using `upsertSearchAttributes()`, which merges the new attributes into the existing set.
99
+
100
+
### Execution and Run Timeouts
101
+
102
+
`StartOptions` also supports execution-level and run-level timeouts:
103
+
104
+
```php
105
+
$workflow->start(
106
+
$orderId,
107
+
(new StartOptions())
108
+
->withExecutionTimeout(86400) // 24 hours across all runs
109
+
->withRunTimeout(3600), // 1 hour per individual run
110
+
);
111
+
```
112
+
113
+
-**Execution timeout** spans the entire workflow instance lifecycle, including retries and continue-as-new runs. Once the execution deadline passes, the engine will not schedule further workflow tasks.
114
+
-**Run timeout** applies to the current run only. It resets when a workflow continues as new.
115
+
116
+
Both timeouts must be at least 1 second. Pass `null` (the default) to leave the timeout unlimited.
117
+
78
118
## Workflow Type
79
119
80
120
The durable `workflow_type` for that instance comes from either:
Both policies record durable command and history events, so you can also assert on `WorkflowCommand` and `WorkflowHistoryEvent` rows for deeper verification.
282
+
283
+
### Testing History Budget
284
+
285
+
The `HistoryBudget` fields (`history_event_count`, `history_size_bytes`, `continue_as_new_recommended`) are surfaced on the run summary projection and are available through the `RunDetailView`. In your workflow code, the `Workflow` base class exposes these as `$this->historyEventCount()`, `$this->historySizeBytes()`, and `$this->continueAsNewRecommended()`:
286
+
287
+
```php
288
+
use Workflow\V2\Workflow;
289
+
290
+
final class LongRunningWorkflow extends Workflow
291
+
{
292
+
public function handle(): void
293
+
{
294
+
while (true) {
295
+
// ... process work ...
296
+
297
+
if ($this->continueAsNewRecommended()) {
298
+
$this->continueAsNew($this->carryForwardState());
299
+
}
300
+
}
301
+
}
302
+
}
303
+
```
304
+
305
+
To test history budget thresholds, configure the thresholds low and verify the recommendation:
306
+
307
+
```php
308
+
public function testHistoryBudgetRecommendsContinueAsNew(): void
0 commit comments