@@ -148,11 +148,11 @@ export DISPATCH_ENDPOINT_URL="https://f441-2600-1700-2802-e01f-6861-dbc9-d551-ec
148148
149149### Durable coroutines for Python
150150
151- Stateful functions can be turned into durable coroutines by declaring them
152- * async* . When doing so, every await point becomes a durable step in the
153- function execution: if the awaited operation fails, it is automatically
154- retried and the parent function is paused until the result becomes available,
155- or a permanent error is raised.
151+ The ` @dispatch.function ` decorator can also be applied to Python coroutines
152+ (a.k.a. * async* functions), in which case each await point on another
153+ stateful function becomes a durability step in the execution: if the awaited
154+ operation fails, it is automatically retried and the parent function is paused
155+ until the result becomes available, or a permanent error is raised.
156156
157157``` python
158158@dispatch.function
@@ -181,8 +181,22 @@ async def transform2(msg):
181181 ...
182182```
183183
184- Note that in order to provide durability guarantees, the awaited functions must
185- be marked with the ` @dispatch.function ` decorator.
184+ This model is composable and can be used to create fan-out/fan-in control flows.
185+ ` gather ` can be used to wait on multiple concurrent calls to stateful functions,
186+ for example:
187+
188+ ``` python
189+ from dispatch import gather
190+
191+ @dispatch.function
192+ async def process (msgs ):
193+ concurrent_calls = [transform(msg) for msg in msgs]
194+ return await gather(* concurrent_calls)
195+
196+ @dispatch.function
197+ async def transform (msg ):
198+ ...
199+ ```
186200
187201## Examples
188202
0 commit comments