24 releases (5 breaking)

0.6.1 Jan 11, 2022
0.6.0 Dec 22, 2021
0.5.5 Dec 15, 2021
0.5.2 Jun 16, 2021
0.2.7 Mar 29, 2021

#133 in Rust patterns

Download history 27/week @ 2021-10-02 76/week @ 2021-10-09 53/week @ 2021-10-16 127/week @ 2021-10-23 51/week @ 2021-10-30 68/week @ 2021-11-06 50/week @ 2021-11-13 55/week @ 2021-11-20 164/week @ 2021-11-27 76/week @ 2021-12-04 107/week @ 2021-12-11 90/week @ 2021-12-18 40/week @ 2021-12-25 34/week @ 2022-01-01 100/week @ 2022-01-08 62/week @ 2022-01-15

242 downloads per month

MIT/Apache

48KB
1K SLoC

Event sourcing.rs

It is an opinionated library used to achieve cqrs/es in Rust.

A complete example can be found in the example folder.

Install

Event Sourcing RS uses under the hood sqlx.

# Cargo.toml
[dependencies]
# postgres database
esrs = { version = "0.5", features = ["postgres"] }
sqlx = { version = "0.5", features = ["postgres", "runtime-tokio-native-tls", "uuid", "json", "chrono"] }
# sqlite database
esrs = { version = "0.5", features = ["sqlite"] }
sqlx = { version = "0.5", features = ["sqlite", "runtime-tokio-native-tls", "uuid", "json", "chrono"] }

Run examples, tests and linting

Payment examples simulate paying with credit card goods or services updating bank account (so its balance).

To run examples and tests first you need to start new postgres instance. You'll not be able to run postgres example and tests otherwise.

docker run -p 5432:5432 --name postgres -e POSTGRES_PASSWORD=postgres -d postgres:11-alpine

Export DATABASE_URL environment variable with freshly new created database.

export DATABASE_URL=postgres://postgres:postgres@localhost:5432/postgres

Run examples.

# Run payments example using postgres database
cargo run --example postgres-payments
# Run payments example using sqlite database
cargo run --example sqlite-payments

Run tests and linting.

# Run tests
cargo test --all-targets --all-features
# Run linting
cargo clippy --all-targets --all-features -- -W clippy::nursery

Finally eventually unset DATABASE_URL environment variable.

unset DATABASE_URL

Dependencies

~11–17MB
~343K SLoC

?a