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
+49-55Lines changed: 49 additions & 55 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -220,25 +220,24 @@ async for event in client.read_events(
220
220
221
221
If you need to abort reading use `break` or `return` within the `async for` loop. However, this only works if there is currently an iteration going on.
222
222
223
-
To abort reading independently of that, hand over an abort signal as third argument when calling `read_events`, and abort the appropriate `AbortController`:
223
+
To abort reading independently of that, store the generator in a variable, and close it explicitly:
224
224
225
225
```python
226
226
from eventsourcingdb import ReadEventsOptions
227
227
228
-
asyncwith client.read_events(
228
+
events = client.read_events(
229
229
subject='/books/42',
230
230
options= ReadEventsOptions(
231
231
recursive=False,
232
232
),
233
-
) as events:
234
-
asyncfor event in events:
235
-
pass
233
+
)
236
234
237
-
# Somewhere else, abort the controller, which will cause
238
-
# reading to end.
239
-
abort()
235
+
asyncfor event in events:
236
+
pass
240
237
241
-
#TODO: Fix this section, also the text above.
238
+
# Somewhere else, abort the generator, which will cause
239
+
# reading to end.
240
+
await events.aclose()
242
241
```
243
242
244
243
### Running EventQL Queries
@@ -261,23 +260,22 @@ async for row in client.run_eventql_query(
261
260
262
261
If you need to abort a query use `break` or `return` within the `async for` loop. However, this only works if there is currently an iteration going on.
263
262
264
-
To abort the query independently of that, hand over an abort signal as second argument when calling `run_eventql_query`, and abort the appropriate AbortController:
263
+
To abort the query independently of that, store the generator in a variable, and close it explicitly:
265
264
266
265
```python
267
-
# const controller = new AbortController();
268
-
269
-
# for await (const row of client.runEventQlQuery(`
270
-
# FROM e IN events
271
-
# PROJECT INTO e
272
-
# `, controller.signal)) {
273
-
# // ...
274
-
# }
266
+
rows = client.run_eventql_query(
267
+
query='''
268
+
FROM e IN events
269
+
PROJECT INTO e
270
+
''',
271
+
)
275
272
276
-
# // Somewhere else, abort the controller, which will cause
277
-
# // the query to end.
278
-
# controller.abort();
273
+
asyncfor row in rows:
274
+
pass
279
275
280
-
#TODO: Fix this section, also the text above.
276
+
# Somewhere else, abort the generator, which will cause
277
+
# the query to end.
278
+
await rows.aclose()
281
279
```
282
280
283
281
### Observing Events
@@ -372,22 +370,24 @@ async for event in client.observe_events(
372
370
373
371
If you need to abort observing use `break` or `return` within the `async for` loop. However, this only works if there is currently an iteration going on.
374
372
375
-
To abort observing independently of that, hand over an abort signal as third argument when calling `observeEvents`, and abort the appropriate `AbortController`:
373
+
To abort observing independently of that, store the generator in a variable, and close it explicitly:
376
374
377
375
```python
378
-
# const controller = new AbortController();
376
+
from eventsourcingdb import ObserveEventsOptions
379
377
380
-
# for await (const event of client.observeEvents('/books/42', {
381
-
# recursive: false
382
-
# }, controller.signal)) {
383
-
# // ...
384
-
# }
378
+
events = client.observe_events(
379
+
subject='/books/42',
380
+
options= ObserveEventsOptions(
381
+
recursive=False
382
+
),
383
+
)
385
384
386
-
# // Somewhere else, abort the controller, which will cause
387
-
# // observing to end.
388
-
# controller.abort();
385
+
asyncfor event in events:
386
+
pass
389
387
390
-
#TODO: Fix example above.
388
+
# Somewhere else, abort the generator, which will cause
389
+
# observing to end.
390
+
await events.aclose()
391
391
```
392
392
393
393
### Registering an Event Schema
@@ -438,22 +438,19 @@ async for subject in client.read_subjects(
438
438
439
439
If you need to abort listing use `break` or `return` within the `async for` loop. However, this only works if there is currently an iteration going on.
440
440
441
-
To abort listing independently of that, hand over an abort signal as second argument when calling `readSubjects`, and abort the appropriate `AbortController`:
441
+
To abort listing independently of that, store the generator in a variable, and close it explicitly:
442
442
443
443
```python
444
-
# const controller = new AbortController();
445
-
446
-
# for await (const subject of client.readSubjects(
447
-
# '/', controller.signal)
448
-
# ) {
449
-
# // ...
450
-
# }
444
+
subjects = client.read_subjects(
445
+
base_subject='/books'
446
+
)
451
447
452
-
# // Somewhere else, abort the controller, which will cause
453
-
# // reading to end.
454
-
# controller.abort();
448
+
asyncfor subject in subjects:
449
+
pass
455
450
456
-
#TODO: Fix the above section.
451
+
# Somewhere else, abort the generator, which will cause
452
+
# reading to end.
453
+
await subjects.aclose()
457
454
```
458
455
459
456
### Listing Event Types
@@ -469,20 +466,17 @@ async for event_type in client.read_event_types():
469
466
470
467
If you need to abort listing use `break` or `return` within the `async for` loop. However, this only works if there is currently an iteration going on.
471
468
472
-
To abort listing independently of that, hand over an abort signal as argument when calling `readEventTypes`, and abort the appropriate `AbortController`:
469
+
To abort listing independently of that, store the generator in a variable, and close it explicitly:
473
470
474
471
```python
475
-
# const controller = new AbortController();
472
+
event_types = client.read_event_types()
476
473
477
-
# for await (const eventType of client.readEventTypes()) {
478
-
# // ...
479
-
# }
480
-
481
-
# // Somewhere else, abort the controller, which will cause
482
-
# // reading to end.
483
-
# controller.abort();
474
+
asyncfor event_type in event_types:
475
+
pass
484
476
485
-
#TODO: Fix the section above.
477
+
# Somewhere else, abort the generator, which will cause
0 commit comments