17 releases
0.4.12 | Sep 13, 2024 |
---|---|
0.4.11 | Feb 20, 2024 |
0.4.10 | Aug 27, 2023 |
0.4.9 | May 27, 2023 |
0.0.1 | Dec 30, 2021 |
#900 in Database interfaces
57KB
1K
SLoC
dynamo-es
A DynamoDB implementation of the
PersistedEventRepository
trait in cqrs-es.
Usage
Add to your Cargo.toml file:
[dependencies]
cqrs-es = "0.4.11"
dynamo-es = "0.4.11"
Requires access to a Dynamo DB with existing tables. See:
- Sample database configuration
- Sample database table layout
- Use
docker-compose
and the./db/create_tables.sh
script to quickly setup a local database
DynamoDb caveats
AWS' DynamoDb is fast, flexible and highly available, but it does set some limitations that must be considered in the design of your application.
Maximum limit of 25 operations in any transaction
Events are inserted in a single transaction, which limits the number of events that can be handled from a single command using this repository. To operate correctly a command must not produce more than
- 25 events if using an event store without snapshots
- 24 events if using snapshots or an aggregate store
Item size limit of 400 KB
A single event should never reach this size, but a large serialized aggregate might. If this is the case for your aggregate beware of using snapshots or an aggregate store.
Maximum request size of 1 MB
This could have the same ramifications as the above for snapshots or an aggregate store. Additionally, an aggregate instance with a large number of events may reach this threshold. To prevent an error while loading or replaying events, set the streaming channel size to a value that ensures you won't exceed this threshold.
Testing
Requires access to DynamoDb with existing tables. This can be created locally using the included
docker-compose.yml
and database initialization script.
To prepare a local test environment (requires a local installation of Docker and AWS CLI):
docker-compose up -d
./db/create_tables.sh
It is recommended that tables are configured to allow only transactions. See: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/transaction-apis-iam.html
Things that could be helpful:
- User guide along with an introduction to CQRS and event sourcing.
- Demo application using the warp http server.
- Change log
Dependencies
~15–22MB
~288K SLoC