Skip to content

Commit

Permalink
[PLATFORM-1127]: Update changelog 2023-06-08 (#160)
Browse files Browse the repository at this point in the history
* Remove --workspace flag to every call since is not useful anymore

* Update changelog with latest PRs details

* Fix wrong PR links in changelog

* Update release date

* Update cargo toml to 0.12.0 version

* Refactor lib's public interface

* Update changelog with #161

* Use thiserror for KafkaEventBusError and RabbitEventBusError

* Delete wrongly remained files and fixed crud example
  • Loading branch information
cottinisimone authored Jun 9, 2023
1 parent 826ec06 commit 967306e
Show file tree
Hide file tree
Showing 14 changed files with 104 additions and 74 deletions.
66 changes: 65 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,58 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

---
## [0.12.0] - 2023-06-09

### Added

- [[#148]]: `ReplayableEventHandler` trait to mark an `EventHandler` as replayable or not. This does not stick to
`TransactionalEventHandlers` since it is taken for granted that they must always be replayable.
- [[#149]]: `PgStoreBuilder` struct, currently the sole method for constructing a `PgStore`.
- [[#151]]: The `EventBus` trait is integrated with the `PgStore` implementation to facilitate the publishing of events
after they have been processed by the handlers.
- [[#152]]: `MigrationHandler` trait to run migrations while building a new `PgStore`.
- [[#155]]: Concrete implementations of the `EventBus` interface for Apache Kafka and RabbitMQ. These implementations
are available under the `rabbit` and `kafka` features.
- [[#155]]: Docker compose file for local development and testing.
- [[#156]]: The `table_name` and `add_event_handler` functions to `PgStore`.
- [[#156]]: Generic `Rebuilder` trait and concrete `PgRebuilder` struct facilities to rebuild a single aggregate. These
implementations are available under the `rebuilder` feature.
- [[#157]]: The `TransactionalEventHandler` now includes a new generic type argument that allow to specify the error
return type.
- [[#157]]: The `EventStore` trait now takes the `Aggregate` as associated type and now includes a new associated type
that allow to specify the error return type.
- [[#157]]: New `PgStoreError` type as error return type for `PgStore`.

### Changed

- [[#148]]: `Projector` and `Policy` no longer exists. Replaced with `EventHandler` and `TransactionalEventHandler`.
- [[#150]]: `AggregateManager` is no longer a trait; it now lives as a struct.
- [[#150]]: The `EventStore`, `PgStore`, `EventHandler`, `TransactionalEventHandler` and `ReplayableEventHandler` types,
previously associated with the `AggregateManager` trait, now have a simplified constraint that they are bound
to the `Aggregate` trait.
- [[#153]]: The `save_event` function in the `PgStore` is now accessible only within the crate scope.
- [[#156]]: The examples have been refactored as external executables and are no longer part of the cargo workspace.
- [[#157]]: The `AggregateManager` type bound has been changed from `Aggregate` to an `EventStore` type.
- [[#157]]:
- [[#157]]: The return type error of the inner functions in `AggregateManager` has been modified from `Aggregate::Error`
to a new type called `AggregateManagerError<E>`. This change introduces a clear differentiation between an
`Aggregate` error and an `EventStore` error.
- [[#157]]: The functions in the `EventStore`, including those in the `PgStore`, now utilize the new error associated type
as their return type.
- [[#161]]: Moved some traits and structs in other packages
- The `esrs::AggregateManager` struct (previously a trait) moved into `esrs::manager` module.
- The `esrs::postgres` module has been relocated and can now be found under `esrs::store::postgres`.
- The `esrs::EventStore`, `esrs::EventStoreLockGuard`, `esrs::StoreEvent` and `esrs::UnlockOnDrop` objects moved to `esrs::store` module.


### Removed

- [[#153]]: `PgStore` getters functions `transactional_event_handlers`, `event_handlers` and `event_buses`.
- [[#153]]: `PgStore` custom `persist` function.
- [[#157]]: The `Clone`, `Send`, and `Sync` bounds on the associated types of `Aggregate` have been eliminated.
- [[#161]]: The `error` module has been removed and is no longer available.

---
## [0.11.0] - 2023-04-03

Expand Down Expand Up @@ -224,7 +276,8 @@ Refer to: [#107], [#108] and [#109]
- Bump min version of supported Rust to 1.58 since <1.58 fails to resolve sqlx-core dep


[Unreleased]: https://github.com/primait/event_sourcing.rs/compare/0.11.0...HEAD
[Unreleased]: https://github.com/primait/event_sourcing.rs/compare/0.12.0...HEAD
[0.12.0]: https://github.com/primait/event_sourcing.rs/compare/0.11.0...0.12.0
[0.11.0]: https://github.com/primait/event_sourcing.rs/compare/0.10.2...0.11.0
[0.10.2]: https://github.com/primait/event_sourcing.rs/compare/0.10.1...0.10.2
[0.10.1]: https://github.com/primait/event_sourcing.rs/compare/0.10.0...0.10.1
Expand All @@ -235,6 +288,17 @@ Refer to: [#107], [#108] and [#109]
[0.7.0]: https://github.com/primait/event_sourcing.rs/compare/0.6.2...0.7.0
[0.6.2]: https://github.com/primait/event_sourcing.rs/compare/0.6.1...0.6.2


[#161]: https://github.com/primait/event_sourcing.rs/pull/161
[#157]: https://github.com/primait/event_sourcing.rs/pull/157
[#156]: https://github.com/primait/event_sourcing.rs/pull/156
[#155]: https://github.com/primait/event_sourcing.rs/pull/155
[#153]: https://github.com/primait/event_sourcing.rs/pull/153
[#152]: https://github.com/primait/event_sourcing.rs/pull/152
[#151]: https://github.com/primait/event_sourcing.rs/pull/151
[#150]: https://github.com/primait/event_sourcing.rs/pull/150
[#149]: https://github.com/primait/event_sourcing.rs/pull/149
[#148]: https://github.com/primait/event_sourcing.rs/pull/148
[#144]: https://github.com/primait/event_sourcing.rs/pull/144
[#141]: https://github.com/primait/event_sourcing.rs/pull/141
[#136]: https://github.com/primait/event_sourcing.rs/pull/136
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "esrs"
readme = "README.md"
repository = "https://github.com/primait/event_sourcing.rs"
rust-version = "1.58.0"
version = "0.11.0"
version = "0.12.0"

[package.metadata.docs.rs]
all-features = true
Expand Down
50 changes: 25 additions & 25 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ dependencies = ["check-ci"]

[tasks.check-ci]
script = [
"cargo check --workspace",
"cargo check --workspace --features=postgres",
"cargo check --workspace --features=kafka",
"cargo check --workspace --features=rabbit",
"cargo check --workspace --features=rebuilder",
"cargo check --workspace --all-features"
"cargo check",
"cargo check --features=postgres",
"cargo check --features=kafka",
"cargo check --features=rabbit",
"cargo check --features=rebuilder",
"cargo check --all-features"
]

# Build
Expand All @@ -33,12 +33,12 @@ dependencies = ["build-ci"]

[tasks.build-ci]
script = [
"cargo build -j 2 --workspace",
"cargo build -j 2 --workspace --features=postgres",
"cargo build -j 2 --workspace --features=kafka",
"cargo build -j 2 --workspace --features=rabbit",
"cargo build -j 2 --workspace --features=rebuilder",
"cargo build -j 2 --workspace --all-features"
"cargo build -j 2",
"cargo build -j 2 --features=postgres",
"cargo build -j 2 --features=kafka",
"cargo build -j 2 --features=rabbit",
"cargo build -j 2 --features=rebuilder",
"cargo build -j 2 --all-features"
]

# Format
Expand All @@ -55,13 +55,13 @@ dependencies = ["test-ci"]
[tasks.test-ci]
description = "Run tests during CI"
script = [
"cargo test ${@} --workspace",
"cargo test ${@} --workspace --features=postgres",
"cargo test ${@} --workspace --features=rebuilder",
"cargo test ${@} --workspace --features=kafka",
"cargo test ${@} --workspace --features=rabbit",
"cargo test ${@} --workspace --features=rebuilder",
"cargo test ${@} --workspace --all-features"
"cargo test ${@}",
"cargo test ${@} --features=postgres",
"cargo test ${@} --features=rebuilder",
"cargo test ${@} --features=kafka",
"cargo test ${@} --features=rabbit",
"cargo test ${@} --features=rebuilder",
"cargo test ${@} --all-features"
]

# Clippy
Expand All @@ -72,12 +72,12 @@ dependencies = ["clippy-ci", "clippy-examples"]
[tasks.clippy-ci]
description = "Run clippy linter during CI"
script = [
"cargo clippy --workspace -- -D warnings",
"cargo clippy --workspace --features=postgres -- -D warnings",
"cargo clippy --workspace --features=kafka -- -D warnings",
"cargo clippy --workspace --features=rabbit -- -D warnings",
"cargo clippy --workspace --features=rebuilder -- -D warnings",
"cargo clippy --workspace --all-features -- -D warnings"
"cargo clippy -- -D warnings",
"cargo clippy --features=postgres -- -D warnings",
"cargo clippy --features=kafka -- -D warnings",
"cargo clippy --features=rabbit -- -D warnings",
"cargo clippy --features=rebuilder -- -D warnings",
"cargo clippy --all-features -- -D warnings"
]

# Run example
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Event Sourcing RS uses under the hood [`sqlx`].
# Cargo.toml
[dependencies]
# postgres database
esrs = { version = "0.11", features = ["postgres"] }
esrs = { version = "0.12", features = ["postgres"] }
sqlx = { version = "0.6", features = ["postgres", "runtime-tokio-native-tls", "uuid", "json", "chrono"] }
```

Expand Down
2 changes: 1 addition & 1 deletion examples/store_crud/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ async fn main() {
};

let query: String = format!(
include_str!("../../src/esrs/sql/postgres/statements/insert.sql"),
include_str!("../../src/sql/postgres/statements/insert.sql"),
store.table_name()
);

Expand Down
20 changes: 5 additions & 15 deletions src/bus/kafka/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,12 @@
/// - `Json`: Indicates a failure in serializing/deserializing the event payload.
/// - `Kafka`: Indicates an error occurred while establishing a connection with the Kafka cluster or
/// an error encountered during the event publishing process.
#[derive(Debug)]
#[derive(thiserror::Error, Debug)]
pub enum KafkaEventBusError {
Json(serde_json::Error),
Kafka(rdkafka::error::KafkaError),
}

impl From<serde_json::Error> for KafkaEventBusError {
fn from(value: serde_json::Error) -> Self {
Self::Json(value)
}
}

impl From<rdkafka::error::KafkaError> for KafkaEventBusError {
fn from(value: rdkafka::error::KafkaError) -> Self {
Self::Kafka(value)
}
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(transparent)]
Kafka(#[from] rdkafka::error::KafkaError),
}

impl From<(rdkafka::error::KafkaError, rdkafka::message::OwnedMessage)> for KafkaEventBusError {
Expand Down
21 changes: 6 additions & 15 deletions src/bus/rabbit/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,12 @@
/// or an error encountered during the event publishing process.
/// - `PublishNack`: Indicates an error encountered during the publishing process, indicating the
/// server responding with a `Nack`.
#[derive(Debug)]
#[derive(thiserror::Error, Debug)]
pub enum RabbitEventBusError {
Json(serde_json::Error),
Rabbit(lapin::Error),
#[error(transparent)]
Json(#[from] serde_json::Error),
#[error(transparent)]
Rabbit(#[from] lapin::Error),
#[error("Received nack on publish")]
PublishNack,
}

impl From<serde_json::Error> for RabbitEventBusError {
fn from(value: serde_json::Error) -> Self {
Self::Json(value)
}
}

impl From<lapin::Error> for RabbitEventBusError {
fn from(value: lapin::Error) -> Self {
Self::Rabbit(value)
}
}
9 changes: 0 additions & 9 deletions src/esrs/sql/postgres/migrations/01_create_table.sql

This file was deleted.

1 change: 0 additions & 1 deletion src/esrs/sql/postgres/migrations/02_create_index.sql

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion src/esrs/sql/postgres/statements/insert.sql

This file was deleted.

1 change: 0 additions & 1 deletion src/esrs/sql/postgres/statements/select_all.sql

This file was deleted.

This file was deleted.

0 comments on commit 967306e

Please sign in to comment.