@@ -15,25 +15,29 @@ Python package to develop applications with the Dispatch platform.
15
15
[ fastapi ] : https://fastapi.tiangolo.com/tutorial/first-steps/
16
16
[ ngrok ] : https://ngrok.com/
17
17
[ pypi ] : https://pypi.org/project/dispatch-py/
18
- [ signup ] : https://docs .dispatch.run/stateful-functions/getting-started
18
+ [ signup ] : https://console .dispatch.run/
19
19
20
20
- [ What is Dispatch?] ( #what-is-dispatch )
21
21
- [ Installation] ( #installation )
22
22
- [ Usage] ( #usage )
23
23
- [ Configuration] ( #configuration )
24
24
- [ Integration with FastAPI] ( #integration-with-fastapi )
25
25
- [ Local testing with ngrok] ( #local-testing-with-ngrok )
26
- - [ Durable coroutines for Python] ( #durable -coroutines-for-python )
26
+ - [ Distributed coroutines for Python] ( #distributed -coroutines-for-python )
27
27
- [ Examples] ( #examples )
28
28
- [ Contributing] ( #contributing )
29
29
30
30
## What is Dispatch?
31
31
32
- Dispatch is a platform for developing reliable distributed systems. Dispatch
33
- provides a simple programming model based on durable coroutines to manage the
34
- scheduling of function calls across a fleet of service instances. Orchestration
35
- of function calls is managed by Dispatch, providing ** fair scheduling** ,
36
- transparent ** retry of failed operations** , and ** durability** .
32
+ Dispatch is a platform for developing scalable & reliable distributed systems.
33
+
34
+ Dispatch provides a simple programming model based on * Distributed Coroutines* ,
35
+ allowing complex, dynamic workflows to be expressed with regular code and
36
+ control flow.
37
+
38
+ Dispatch schedules function calls across a fleet of service instances,
39
+ incorporating ** fair scheduling** , transparent ** retry of failed operations** ,
40
+ and ** durability** .
37
41
38
42
To get started, follow the instructions to [ sign up for Dispatch] [ signup ] 🚀.
39
43
@@ -46,32 +50,34 @@ pip install dispatch-py
46
50
47
51
## Usage
48
52
49
- The SDK allows Python applications to declare * Stateful Functions * that the
50
- Dispatch scheduler can orchestrate. This is the bare minimum structure used
51
- to declare stateful functions:
53
+ The SDK allows Python applications to declare functions that Dispatch can
54
+ orchestrate:
55
+
52
56
``` python
53
57
@dispatch.function
54
58
def action (msg ):
55
59
...
56
60
```
61
+
57
62
The ** @dispatch .function** decorator declares a function that can be run by
58
- the Dispatch scheduler. The call has durable execution semantics; if the
59
- function fails with a temporary error, it is automatically retried, even if
60
- the program is restarted, or if multiple instances are deployed.
63
+ Dispatch. The call has durable execution semantics; if the function fails
64
+ with a temporary error, it is automatically retried, even if the program is
65
+ restarted, or if multiple instances are deployed.
66
+
67
+ The SDK adds a method to the ` action ` object, allowing the program to
68
+ dispatch an asynchronous invocation of the function; for example:
61
69
62
- In this example, the decorator adds a method to the ` action ` object, allowing
63
- the program to dispatch an asynchronous invocation of the function; for example:
64
70
``` python
65
71
action.dispatch(' hello' )
66
72
```
67
73
68
74
### Configuration
69
75
70
- To interact with stateful functions, the SDK needs to be configured with the
71
- address at which the server can be reached. The Dispatch API Key must also be
72
- set, and optionally, a public signing key should be configured to verify that
73
- requests received by the stateful functions originated from the Dispatch
74
- scheduler. These configuration options can be passed as arguments to the
76
+ In order for Dispatch to interact with functions remotely , the SDK needs to be
77
+ configured with the address at which the server can be reached. The Dispatch
78
+ API Key must also be set, and optionally, a public signing key should be
79
+ configured to verify that requests originated from Dispatch. These
80
+ configuration options can be passed as arguments to the
75
81
the ` Dispatch ` constructor, but by default they will be loaded from environment
76
82
variables:
77
83
@@ -82,7 +88,7 @@ variables:
82
88
| ` DISPATCH_VERIFICATION_KEY ` | ` -----BEGIN PUBLIC KEY-----... ` |
83
89
84
90
Finally, the ` Dispatch ` instance needs to mount a route on a HTTP server in to
85
- receive requests from the scheduler . At this time, the SDK integrates with
91
+ receive requests from Dispatch . At this time, the SDK integrates with
86
92
FastAPI; adapters for other popular Python frameworks will be added in the
87
93
future.
88
94
@@ -111,12 +117,11 @@ def root():
111
117
```
112
118
113
119
In this example, GET requests on the HTTP server dispatch calls to the
114
- ` publish ` stateful function. The function runs concurrently to the rest of the
115
- program, driven by the Dispatch scheduler .
120
+ ` publish ` function. The function runs concurrently to the rest of the
121
+ program, driven by the Dispatch SDK .
116
122
117
123
The instantiation of the ` Dispatch ` object on the ` FastAPI ` application
118
- automatically installs the HTTP route needed for the scheduler to run stateful
119
- functions.
124
+ automatically installs the HTTP route needed for Dispatch to invoke functions.
120
125
121
126
### Local testing with ngrok
122
127
@@ -149,13 +154,13 @@ different value, but in this example it would be:
149
154
export DISPATCH_ENDPOINT_URL=" https://f441-2600-1700-2802-e01f-6861-dbc9-d551-ecfb.ngrok-free.app"
150
155
```
151
156
152
- ### Durable coroutines for Python
157
+ ### Distributed Coroutines for Python
153
158
154
159
The ` @dispatch.function ` decorator can also be applied to Python coroutines
155
- (a.k.a. * async* functions), in which case each await point on another
156
- stateful function becomes a durability step in the execution: if the awaited
157
- operation fails, it is automatically retried and the parent function is paused
158
- until the result becomes available, or a permanent error is raised.
160
+ (a.k.a. * async* functions), in which case each ` await ` point becomes a
161
+ durability step in the execution. If the awaited operation fails, it is
162
+ automatically retried, and the parent function is paused until the result are
163
+ available or a permanent error is raised.
159
164
160
165
``` python
161
166
@dispatch.function
@@ -185,8 +190,7 @@ async def transform2(msg):
185
190
```
186
191
187
192
This model is composable and can be used to create fan-out/fan-in control flows.
188
- ` gather ` can be used to wait on multiple concurrent calls to stateful functions,
189
- for example:
193
+ ` gather ` can be used to wait on multiple concurrent calls:
190
194
191
195
``` python
192
196
from dispatch import gather
@@ -201,6 +205,9 @@ async def transform(msg):
201
205
...
202
206
```
203
207
208
+ Dispatch converts Python coroutines to * Distributed Coroutines* , which can be
209
+ suspended and resumed on any instance of a service across a fleet.
210
+
204
211
### Serialization
205
212
206
213
Dispatch uses the [ pickle] library to serialize coroutines.
0 commit comments