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: README.md
+203-2Lines changed: 203 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,7 +118,7 @@ Orchestrations can start child orchestrations using the `call_sub_orchestrator`
118
118
119
119
Orchestrations can wait for external events using the `wait_for_external_event` API. External events are useful for implementing human interaction patterns, such as waiting for a user to approve an order before continuing.
120
120
121
-
### Continue-as-new (TODO)
121
+
### Continue-as-new
122
122
123
123
Orchestrations can be continued as new using the `continue_as_new` API. This API allows an orchestration to restart itself from scratch, optionally with a new input.
124
124
@@ -214,6 +214,9 @@ The following is more information about how to develop this project. Note that d
214
214
### Generating protobufs
215
215
216
216
```sh
217
+
# install dev dependencies for generating protobufs and running tests
To run the E2E tests on a specific python version (eg: 3.11), run the following command from the project root:
253
256
254
257
```sh
255
-
tox -e py311 -- e2e
258
+
tox -e py311-e2e
259
+
```
260
+
261
+
### Configuration
262
+
263
+
#### Connection Configuration
264
+
265
+
The SDK connects to a Durable Task sidecar. By default it uses `localhost:4001`. You can override via environment variables (checked in order):
266
+
267
+
-`DAPR_GRPC_ENDPOINT` - Full endpoint (e.g., `localhost:4001`, `grpcs://host:443`)
268
+
-`DAPR_GRPC_HOST` (or `DAPR_RUNTIME_HOST`) and `DAPR_GRPC_PORT` - Host and port separately
269
+
270
+
Example (common ports: 4001 for DurableTask-Go emulator, 50001 for Dapr sidecar):
271
+
272
+
```sh
273
+
export DAPR_GRPC_ENDPOINT=localhost:4001
274
+
# or
275
+
export DAPR_GRPC_HOST=localhost
276
+
export DAPR_GRPC_PORT=50001
277
+
```
278
+
279
+
280
+
#### Async Workflow Configuration
281
+
282
+
Configure async workflow behavior and debugging:
283
+
284
+
-`DAPR_WF_DISABLE_DETECTION` - Disable non-determinism detection (set to `true`)
285
+
286
+
Example:
287
+
288
+
```sh
289
+
export DAPR_WF_DISABLE_DETECTION=false
290
+
```
291
+
292
+
### Async workflow authoring
293
+
294
+
For a deeper tour of the async authoring surface (determinism helpers, sandbox modes, timeouts, concurrency patterns), see the Async Enhancements guide: [ASYNC_ENHANCEMENTS.md](./ASYNC_ENHANCEMENTS.md). The developer-facing migration notes are in [DEVELOPER_TRANSITION_GUIDE.md](./DEVELOPER_TRANSITION_GUIDE.md).
295
+
296
+
You can author orchestrators with `async def` using the new `durabletask.aio` package, which provides a comprehensive async workflow API:
Optional sandbox mode (`best_effort` or `strict`) patches `asyncio.sleep`, `random`, `uuid.uuid4`, and `time.time` within the workflow step to deterministic equivalents. This is best-effort and not a correctness guarantee.
313
+
314
+
In `strict` mode, `asyncio.create_task` is blocked inside workflows to preserve determinism and will raise a `SandboxViolationError` if used.
315
+
316
+
> **Enhanced Sandbox Features**: The enhanced version includes comprehensive non-determinism detection, timeout support, enhanced concurrency primitives, and debugging tools. See [ASYNC_ENHANCEMENTS.md](./durabletask/aio/ASYNCIO_ENHANCEMENTS.md) for complete documentation.
317
+
318
+
#### Async patterns
319
+
320
+
- Activities and sub-orchestrations can be referenced by function object or by their registered string name. Both forms are supported:
321
+
- Function reference (preferred for IDE/type support) or string name (useful across modules/languages).
322
+
323
+
- Activities:
324
+
```python
325
+
result =await ctx.call_activity("process", input={"x": 1})
326
+
# or: result = await ctx.call_activity(process, input={"x": 1})
327
+
```
328
+
329
+
- Timers:
330
+
```python
331
+
await ctx.sleep(1.5) # seconds or timedelta
332
+
```
333
+
334
+
- External events:
335
+
```python
336
+
val =await ctx.wait_for_external_event("approval")
- Async authoring (`durabletask.aio`): awaiting returns the operation's value. Exceptions are raised on `await` (no `is_failed`).
354
+
- Generator authoring (`durabletask.task`): yielding returns `Task` objects. Use `get_result()` to read values; failures surface via `is_failed()` or by raising on `get_result()`.
355
+
356
+
Examples:
357
+
358
+
```python
359
+
# Async authoring (await returns value)
360
+
# when_any returns a proxy that compares equal to the original awaitable
361
+
# and exposes get_result() for the completed item.
- Useful for routing, observability, and cross-cutting concerns passed along activity/sub-orchestrator calls via the sidecar.
425
+
- In python-sdk, available for both async and generator orchestrators. In this repo, currently implemented on `durabletask.aio`; generator parity is planned.
426
+
427
+
- Cross-app activity/sub-orchestrator routing (async only for now):
428
+
```python
429
+
# Route activity to a different app via app_id
430
+
result =await ctx.call_activity("process", input=data, app_id="worker-app-2")
0 commit comments