Qx projection runner: rebuild and incrementally update read models from the event log
Project description
qx-projections
Projection runner for Qx services. Reads from the qx_aggregate_events event log and drives
incremental or full-rebuild updates of read models.
Usage
from qx.projections import Projection, ProjectionRunner, include_projection_tables
class OrderCountProjection(Projection):
name = "order_count"
async def on_orderplaced(self, ev: OrderPlaced) -> None:
await self._session.execute(
"INSERT INTO order_counts (id, count) VALUES (:id, 1) "
"ON CONFLICT (id) DO UPDATE SET count = count + 1",
{"id": ev.tenant_id},
)
runner = ProjectionRunner(checkpoints_table, events_table)
runner.register(OrderCountProjection())
# Incremental (call periodically)
async with session_factory() as session:
await runner.run_once(session)
# Full rebuild
async with session_factory() as session:
await runner.rebuild(session, projection_name="order_count")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
qx_projections-1.1.0.tar.gz
(5.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file qx_projections-1.1.0.tar.gz.
File metadata
- Download URL: qx_projections-1.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7ca435a2c439c12356228b99e3e306de626517cadfe5c377b96bd77939b0dd76
|
|
| MD5 |
0aa4c4c3c2b3c35f26b219dc3c14b7f3
|
|
| BLAKE2b-256 |
1dbb5739a90617457b6ddf73d8511bcfd0b76a32817076f9f1681c2f7af4107d
|
File details
Details for the file qx_projections-1.1.0-py3-none-any.whl.
File metadata
- Download URL: qx_projections-1.1.0-py3-none-any.whl
- Upload date:
- Size: 5.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38af4ff6dfa042a1b2e9d8dec50277d1a7e58ee10763e037bbf67f8b911862f3
|
|
| MD5 |
e2f65bb954fb22b21fb6afab27c4fbe5
|
|
| BLAKE2b-256 |
1f849c3902af58c44b989daef76f853987d734aea3181d4b11dd7866dd5b7a7d
|