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.0.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.0.0.tar.gz.
File metadata
- Download URL: qx_projections-1.0.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 |
8fcd80e61c660b6584880aefc96324784beb6744fc8b34a8b60c377f20127ec4
|
|
| MD5 |
329200d6fb36c3c084d6d7f90adf40da
|
|
| BLAKE2b-256 |
22bc3cb96305005052e9ef8698220d8ad5f540399eeca049dbc0d3366cf62485
|
File details
Details for the file qx_projections-1.0.0-py3-none-any.whl.
File metadata
- Download URL: qx_projections-1.0.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 |
93926e165e80c832872edb3b1db507e0f5b7a687b5da7a85cf1ad93ec436bfc4
|
|
| MD5 |
d78c5958ff046c44324541f21b221420
|
|
| BLAKE2b-256 |
ffc0187baf250caf67ab0a93c541471bfb2f59911abda81976f49e322ac22cb4
|