Event Sourcing with UmaDB
This package supports using the Python eventsourcing library with UmaDB.
Installation
Use pip to install the stable distribution from the Python Package Index.
$ pip install eventsourcing-umadb
Please note, it is recommended to install Python packages into a Python virtual environment.
Getting started
Use the eventsourcing.dcb package to define a DCB application. Read the docs for more information.
from typing import Any, Dict, cast
from eventsourcing.dcb.application import DCBApplication
from eventsourcing.dcb.domain import EnduringObject
from eventsourcing.dcb.msgpack import Decision, InitialDecision, MessagePackMapper
from eventsourcing.domain import event
from eventsourcing.utils import get_topic
class TrainingSchool(DCBApplication):
env = {"MAPPER_TOPIC": get_topic(MessagePackMapper)}
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 = cast(Dog, self.repository.get(dog_id))
dog.add_trick(trick)
self.repository.save(dog)
def get_dog(self, dog_id: str) -> Dict[str, Any]:
dog = cast(Dog, self.repository.get(dog_id))
return {"name": dog.name, "tricks": tuple(dog.tricks)}
class Dog(EnduringObject[Decision, str]):
class Registered(InitialDecision):
dog_id: str
name: str
class TrickAdded(Decision):
trick: str
@event(Registered)
def __init__(self, *, name: str) -> None:
self.name = name
self.tricks: list[str] = []
@event(TrickAdded)
def add_trick(self, trick: str) -> None:
self.tricks.append(trick)
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.
Developers
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
Metadata
Release files for eventsourcing-umadb 0.3.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eventsourcing_umadb-0.3.7.tar.gz | 6.5 kB | Without provenance | Details for eventsourcing_umadb-0.3.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eventsourcing_umadb-0.3.7-py3-none-any.whl | Python 3 | none | any | Details for eventsourcing_umadb-0.3.7-py3-none-any.whl |
Total release size: 13.8 kB
Release files / eventsourcing_umadb-0.3.7.tar.gz
| Download URL | eventsourcing_umadb-0.3.7.tar.gz |
|---|---|
| Size | 6.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e23314541696132fe500627e075ec905ff8aac7affacc05ddb926ed28fe67317
|
|
BLAKE2b-256 checksum How to use checksums |
aa11a6348bf5084d5d68f3bf6a0e674bace90cbd18b3e92a70780a427b74d6ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.14.10 Darwin/25.6.0
|
Release files / eventsourcing_umadb-0.3.7-py3-none-any.whl
| Download URL | eventsourcing_umadb-0.3.7-py3-none-any.whl |
|---|---|
| Size | 7.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e544e5bdde933d21ecbcaaa64c244d0d3589ba1cfa64d806192289fe75bb4a76
|
|
BLAKE2b-256 checksum How to use checksums |
9d5166ff2cc207d1c06f4080acab46e64c1f7faf813c6cfed9183b8a257d1a29
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.2.1 CPython/3.14.10 Darwin/25.6.0
|
Security for eventsourcing-umadb 0.3.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.