Skip to content

Commit 484a67b

Browse files
committed
before_commit callback in middleware
1 parent 40fe808 commit 484a67b

4 files changed

Lines changed: 6 additions & 6 deletions

File tree

docs/examples/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ <h3 id="read-your-own-writes">Read Your Own Writes</h3>
380380
<p>The implementation uses the PostgreSQL WAL LSN (Log Sequence Number).
381381
After a write transaction the current LSN is captured via <code>before_commit</code> and sent to the client
382382
as a cookie.
383-
On the next read the client echoes the cookie back, and The application can use LSN
383+
On the next read the client echoes the cookie back, and the application can use LSN
384384
to select which replica to send a request to (the one that has already caught up) or
385385
send it to the master if no replica has caught up yet.</p>
386386
<p><strong>Step 1 — capture the LSN in <code>before_commit</code></strong></p>
@@ -446,7 +446,7 @@ <h3 id="read-your-own-writes">Read Your Own Writes</h3>
446446
app.add_middleware(BaseHTTPMiddleware, dispatch=lsn_cookie_middleware)
447447
</code></pre>
448448
<p>The full, runnable implementation is available in
449-
<a href="../../examples/fastapi_example/read_own_writes.py">examples/fastapi_example/read_own_writes.py</a>.</p>
449+
<a href="https://github.com/krylosov-aa/context-async-sqlalchemy/blob/main/examples/fastapi_example/read_own_writes.py">examples/fastapi_example/read_own_writes.py</a>.</p>
450450
<p><strong>Step 4 — route reads to the right replica</strong></p>
451451
<p>This example does not cover how to select a replica that has already caught up to the LSN from
452452
the cookie. To do that you need to query each replica's current WAL replay position and compare

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,5 +221,5 @@ <h2 id="how-it-works">How it works</h2>
221221

222222
<!--
223223
MkDocs version : 1.6.1
224-
Build Date UTC : 2026-06-14 09:53:08.796219+00:00
224+
Build Date UTC : 2026-06-14 09:58:13.069749+00:00
225225
-->

docs/search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

docs_sources/docs/examples.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ always see the data that was just written — even when reads are served by a re
290290
The implementation uses the PostgreSQL WAL LSN (Log Sequence Number).
291291
After a write transaction the current LSN is captured via `before_commit` and sent to the client
292292
as a cookie.
293-
On the next read the client echoes the cookie back, and The application can use LSN
293+
On the next read the client echoes the cookie back, and the application can use LSN
294294
to select which replica to send a request to (the one that has already caught up) or
295295
send it to the master if no replica has caught up yet.
296296

@@ -366,7 +366,7 @@ app.add_middleware(BaseHTTPMiddleware, dispatch=lsn_cookie_middleware)
366366
```
367367

368368
The full, runnable implementation is available in
369-
[examples/fastapi_example/read_own_writes.py](../../examples/fastapi_example/read_own_writes.py).
369+
[examples/fastapi_example/read_own_writes.py](https://github.com/krylosov-aa/context-async-sqlalchemy/blob/main/examples/fastapi_example/read_own_writes.py).
370370

371371
**Step 4 — route reads to the right replica**
372372

0 commit comments

Comments
 (0)