Skip to content

Commit 0c91213

Browse files
Update README
1 parent 3036dca commit 0c91213

1 file changed

Lines changed: 1 addition & 29 deletions

File tree

README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
140140
```python
141141
from deepslate import flow
142142

143-
144143
@flow
145144
async def add(a: int, b: int) -> int:
146145
return a + b
@@ -166,12 +165,11 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
166165

167166
- **return**: return a value or exit the flow, e.g. `return result` or bare `return`
168167

169-
- **isinstance**: narrow a `T | DSError` union, the idiomatic error check
168+
- **DSError and isinstance**: deepslate does not support exceptions, durable operations return the result type `T | DSError`, narrow it with `isinstance` on the success type and propagate by returning the error
170169

171170
```python
172171
from deepslate import flow, http_listen, DSError
173172

174-
175173
@flow
176174
async def handle():
177175
data: bytes | DSError
@@ -185,7 +183,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
185183
```python
186184
from deepslate import flow, sleep
187185

188-
189186
@flow
190187
async def delay():
191188
sleep(1.0)
@@ -196,7 +193,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
196193
```python
197194
from deepslate import flow, http_listen, DSError
198195

199-
200196
@flow
201197
async def listener():
202198
data: bytes | DSError
@@ -208,7 +204,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
208204
```python
209205
from deepslate import flow, http_request, DSError
210206

211-
212207
@flow
213208
async def fetch():
214209
resp: bytes | DSError
@@ -220,7 +215,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
220215
```python
221216
from deepslate import flow, json_marshal, json_unmarshal, DSError
222217

223-
224218
@flow
225219
async def codec(data: bytes):
226220
nums: list[int] | DSError
@@ -234,7 +228,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
234228
```python
235229
from deepslate import pure
236230

237-
238231
@pure
239232
def get_status(resp: HealthResponse) -> str:
240233
return resp.Status
@@ -247,7 +240,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
247240

248241
from deepslate import flow, impure
249242

250-
251243
@impure
252244
def insert_event(name: str) -> None:
253245
conn = psycopg2.connect(DBURL)
@@ -267,7 +259,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
267259
```python
268260
from deepslate import flow
269261

270-
271262
@flow
272263
async def adder(a: int, b: int) -> int:
273264
return a + b
@@ -283,7 +274,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
283274
```python
284275
from deepslate import flow, sleep, dpslio
285276

286-
287277
@flow
288278
async def child(n: int):
289279
sleep(1.0)
@@ -299,7 +289,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
299289
```python
300290
from deepslate import flow, dpslio
301291

302-
303292
@flow
304293
async def consumer(ch: dpslio.Queue[int]):
305294
value: int = await ch.get()
@@ -317,7 +306,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
317306
```python
318307
from deepslate import flow, sleep, dpslio
319308

320-
321309
@flow
322310
async def task(wg: dpslio.WaitGroup):
323311
sleep(1.0)
@@ -338,7 +326,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
338326
```python
339327
from deepslate import flow, dpslio
340328

341-
342329
@flow
343330
async def worker(mu: dpslio.Lock):
344331
await mu.acquire()
@@ -351,7 +338,6 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
351338
```python
352339
from deepslate import flow, dpslio
353340

354-
355341
@flow
356342
async def race(ch1: dpslio.Queue[int], ch2: dpslio.Queue[int]):
357343
result: int = 0
@@ -361,17 +347,3 @@ You can think of a `@flow` function as a durable goroutine that can survive appl
361347
case _ if v := await ch2.get():
362348
result = v
363349
```
364-
365-
- **DSError**: deepslate does not support exceptions, instead the result type `T | DSError` is used, check with `isinstance` and propagate by returning the error
366-
367-
```python
368-
from deepslate import flow, json_marshal, DSError
369-
370-
371-
@flow
372-
async def encode():
373-
raw: bytes | DSError
374-
raw = json_marshal([1, 2, 3])
375-
if not isinstance(raw, bytes):
376-
return raw
377-
```

0 commit comments

Comments
 (0)