Event Sourcing with UmaDB
This package supports using the Python eventsourcing library with UmaDB.
Installation
Add the Python eventsourcing package to your project with the umadb option.
Run uv init to start a new project.
uv add "eventsourcing[umadb,pydantic]~=10.0.0a3"
Pydantic is recommended for modelling and serialising events.
After installing, you can start the UmaDB server with uv run umadb.
Getting started
Use the eventsourcing.dcb package to define a DCB application. Read the docs for more information.
from typing import TypedDict
from uuid import uuid4
from eventsourcing.decorator import triggers
from eventsourcing.pydantic import DcbApplication, Decision, EnduringObject
class Dog(EnduringObject):
class Registered(Decision):
dog_id: str
name: str
class TrickAdded(Decision):
dog_id: str
trick: str
@triggers(Registered)
def __init__(self, *, name: str) -> None:
self.name = name
self.tricks: list[str] = []
@triggers(TrickAdded)
def add_trick(self, trick: str) -> None:
self.tricks.append(trick)
class TrainingSchool(DcbApplication):
def register(self, name: str) -> str:
dog = Dog(name=name)
self.repository.save(dog)
return dog.id
def add_trick(self, dog_id: str, trick: str) -> None:
dog = self.repository.get(dog_id, Dog)
dog.add_trick(trick)
self.repository.save(dog)
def get_dog(self, dog_id: str) -> DogSummary:
dog = self.repository.get(dog_id, Dog)
return {"name": dog.name, "tricks": tuple(dog.tricks)}
class DogSummary(TypedDict):
name: str
tricks: tuple[str, ...]
Configure the application to use UmaDB. Set environment variable
PERSISTENCE_MODULE to 'eventsourcing_umadb', and set
UMADB_URI to your UmaDB URI.
app = TrainingSchool(env={
"PERSISTENCE_MODULE": "eventsourcing_umadb",
"UMADB_URI": "http://127.0.0.1:50051",
})
The application's methods may be then called, from tests and user interfaces.
# Register dog.
dog_id = app.register("Fido")
# Add tricks.
app.add_trick(dog_id, "roll over")
app.add_trick(dog_id, "play dead")
# Get details.
dog = app.get_dog(dog_id)
assert dog["name"] == "Fido"
assert dog["tricks"] == ("roll over", "play dead")
For more information, please refer to the Python eventsourcing library and the UmaDB project.
Community
Join the Event Sourcing in Python Discord server today.
Contributors
Clone the GitHub repo and the use the following make commands.
Install Poetry.
make install-poetry
Install packages.
make install
Start UmaDB.
make start-umadb
Run tests.
make test
Stop UmaDB.
make stop-umadb
Check the formatting of the code.
make lint
Reformat the code.
make fmt
Tests belong in ./tests.
Edit package dependencies in pyproject.toml. Update installed packages (and the
poetry.lock file) using the following command.
make update
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 eventsourcing_umadb-0.4.5.tar.gz.
File metadata
- Download URL: eventsourcing_umadb-0.4.5.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.2.1 CPython/3.14.6 Darwin/25.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e746c1f96e802f2ae2d97d184197d7069cbf7d9812989b399f42ff53b4b5b8bb
|
|
| MD5 |
c6c32eb774b2ff95dcad0327dbc74ac2
|
|
| BLAKE2b-256 |
3d4e6741a0d806a6562c579505bdc54837761d71e6aeaa5cec1164dde1498107
|
File details
Details for the file eventsourcing_umadb-0.4.5-py3-none-any.whl.
File metadata
- Download URL: eventsourcing_umadb-0.4.5-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/2.2.1 CPython/3.14.6 Darwin/25.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
142a55505066c80f5c9c880e319c660211739e816a6b36174bba47cd30f30356
|
|
| MD5 |
b92c43402d590aad1c37650678bebf3c
|
|
| BLAKE2b-256 |
9b224de504b79e4fd1d22c94acc0254f118bf79ffc330b4ed9653d82eb98dc7c
|