From 4dcc81a328e037930de566f96ea23914c6fba2cc Mon Sep 17 00:00:00 2001 From: Ivan Dugalic Date: Sun, 31 Dec 2023 10:41:57 +0100 Subject: [PATCH] removed `async_trait` in favour of Rust native async feature --- .github/workflows/rust.yml | 22 ++++++++++++++----- Cargo.lock | 12 ---------- Cargo.toml | 1 - .../publisher/order_action_publisher.rs | 2 -- src/adapter/repository/event_repository.rs | 2 -- .../repository/order_event_repository.rs | 2 -- .../repository/order_view_state_repository.rs | 4 ---- .../repository/restaurant_event_repository.rs | 2 -- .../restaurant_view_state_repository.rs | 4 ---- src/application/api.rs | 3 --- 10 files changed, 16 insertions(+), 38 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f56edca..78f14cf 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,11 +12,21 @@ env: jobs: build: - runs-on: ubuntu-latest + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ ubuntu-latest, windows-latest, macOS-latest ] + rust: [ stable, nightly ] steps: - - uses: actions/checkout@v4 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose + - uses: hecrj/setup-rust-action@v2 + with: + rust-version: ${{ matrix.rust }} + + - uses: actions/checkout@v4 + + - name: Build + run: cargo build --verbose + + - name: Run tests + run: cargo test --verbose diff --git a/Cargo.lock b/Cargo.lock index 5e53bfe..68e7b38 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,17 +270,6 @@ dependencies = [ "libc", ] -[[package]] -name = "async-trait" -version = "0.1.74" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a66537f1bb974b254c98ed142ff995236e81b9d0fe4db0575f46612cb15eb0f9" -dependencies = [ - "proc-macro2", - "quote", - "syn 2.0.38", -] - [[package]] name = "atoi" version = "2.0.0" @@ -697,7 +686,6 @@ dependencies = [ "actix-cors", "actix-rt", "actix-web", - "async-trait", "chrono", "dotenv", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index 7f71661..47fb239 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,6 @@ authors = ["Ivan Dugalic "] [dependencies] fmodel-rust = "0.7.0" -async-trait = "0.1.74" actix-cors = "0.6.5" actix-web = "4.4.0" actix-rt = "2.9.0" diff --git a/src/adapter/publisher/order_action_publisher.rs b/src/adapter/publisher/order_action_publisher.rs index 5557f6f..fe6f976 100644 --- a/src/adapter/publisher/order_action_publisher.rs +++ b/src/adapter/publisher/order_action_publisher.rs @@ -2,7 +2,6 @@ use crate::adapter::database::error::ErrorMessage; use crate::adapter::repository::order_event_repository::OrderEventRepository; use crate::application::api::OrderAggregate; use crate::domain::api::OrderCommand; -use async_trait::async_trait; use fmodel_rust::saga_manager::ActionPublisher; use std::sync::Arc; @@ -12,7 +11,6 @@ pub struct OrderActionPublisher<'a> { } /// Fmodel action publisher implementation fot the OrderActionPublisher -#[async_trait] impl ActionPublisher for OrderActionPublisher<'_> { async fn publish(&self, commands: &[OrderCommand]) -> Result, ErrorMessage> { for command in commands { diff --git a/src/adapter/repository/event_repository.rs b/src/adapter/repository/event_repository.rs index b4347cb..887e1c1 100644 --- a/src/adapter/repository/event_repository.rs +++ b/src/adapter/repository/event_repository.rs @@ -1,5 +1,4 @@ use crate::adapter::repository::ToNewEventEntity; -use async_trait::async_trait; use fmodel_rust::aggregate::EventRepository; use uuid::Uuid; @@ -22,7 +21,6 @@ impl AggregateEventRepository { } /// EventRepository - implementation of Fmodel EventRepository for Command, Event, Uuid, ErrorMessage -#[async_trait] impl EventRepository for AggregateEventRepository { async fn fetch_events(&self, command: &Command) -> Result, ErrorMessage> { // https://doc.rust-lang.org/rust-by-example/error/iter_result.html#fail-the-entire-operation-with-collect diff --git a/src/adapter/repository/order_event_repository.rs b/src/adapter/repository/order_event_repository.rs index 35e1962..9e44108 100644 --- a/src/adapter/repository/order_event_repository.rs +++ b/src/adapter/repository/order_event_repository.rs @@ -1,5 +1,4 @@ use crate::adapter::repository::ToNewEventEntity; -use async_trait::async_trait; use fmodel_rust::aggregate::EventRepository; use uuid::Uuid; @@ -22,7 +21,6 @@ impl OrderEventRepository { } /// OrderEventRepository - implementation of Fmodel EventRepository for OrderCommand, OrderEvent, Uuid, ErrorMessage -#[async_trait] impl EventRepository for OrderEventRepository { async fn fetch_events( &self, diff --git a/src/adapter/repository/order_view_state_repository.rs b/src/adapter/repository/order_view_state_repository.rs index 3893b84..c0402e8 100644 --- a/src/adapter/repository/order_view_state_repository.rs +++ b/src/adapter/repository/order_view_state_repository.rs @@ -1,5 +1,3 @@ -use async_trait::async_trait; - use fmodel_rust::materialized_view::ViewStateRepository; use crate::adapter::database::entity::OrderEntity; @@ -24,7 +22,6 @@ impl OrderViewStateRepository { } /// Implementation of OrderQueryHandler for OrderViewStateRepository -#[async_trait] impl OrderQueryHandler for OrderViewStateRepository { /// Get the Order view state by `id` async fn get_order(&self, id: &str) -> Result, ErrorMessage> { @@ -44,7 +41,6 @@ impl OrderQueryHandler for OrderViewStateRepository { } /// OrderViewStateRepository - implementation of Fmodel ViewStateRepository for OrderEvent, OrderViewState, ErrorMessage -#[async_trait] impl ViewStateRepository, ErrorMessage> for OrderViewStateRepository { diff --git a/src/adapter/repository/restaurant_event_repository.rs b/src/adapter/repository/restaurant_event_repository.rs index 872e901..16d1ffa 100644 --- a/src/adapter/repository/restaurant_event_repository.rs +++ b/src/adapter/repository/restaurant_event_repository.rs @@ -1,5 +1,4 @@ use crate::adapter::repository::ToNewEventEntity; -use async_trait::async_trait; use fmodel_rust::aggregate::EventRepository; use uuid::Uuid; @@ -22,7 +21,6 @@ impl RestaurantEventRepository { } /// RestaurantEventRepository - implementation of Fmodel EventRepository for RestaurantCommand, RestaurantEvent, Uuid, ErrorMessage -#[async_trait] impl EventRepository for RestaurantEventRepository { diff --git a/src/adapter/repository/restaurant_view_state_repository.rs b/src/adapter/repository/restaurant_view_state_repository.rs index fe57d7b..2aeaece 100644 --- a/src/adapter/repository/restaurant_view_state_repository.rs +++ b/src/adapter/repository/restaurant_view_state_repository.rs @@ -1,5 +1,3 @@ -use async_trait::async_trait; - use fmodel_rust::materialized_view::ViewStateRepository; use crate::adapter::database::entity::RestaurantEntity; @@ -24,7 +22,6 @@ impl RestaurantViewStateRepository { } /// Implementation of RestaurantQueryHandler for RestaurantViewStateRepository -#[async_trait] impl RestaurantQueryHandler for RestaurantViewStateRepository { /// Get the Restaurant view state by `id` async fn get_restaurant(&self, id: &str) -> Result, ErrorMessage> { @@ -44,7 +41,6 @@ impl RestaurantQueryHandler for RestaurantViewStateRepository { } /// RestaurantViewStateRepository - implementation of Fmodel ViewStateRepository for RestaurantEvent, RestaurantViewState, ErrorMessage -#[async_trait] impl ViewStateRepository, ErrorMessage> for RestaurantViewStateRepository { diff --git a/src/application/api.rs b/src/application/api.rs index 30089da..18b26d3 100644 --- a/src/application/api.rs +++ b/src/application/api.rs @@ -1,4 +1,3 @@ -use async_trait::async_trait; use fmodel_rust::aggregate::{EventRepository, EventSourcedAggregate}; use fmodel_rust::decider::Decider; use fmodel_rust::materialized_view::MaterializedView; @@ -38,7 +37,6 @@ pub type RestaurantAggregate<'a, R> = EventSourcedAggregate< >; /// RestaurantQueryHandler trait - Query side of CQRS pattern -#[async_trait] pub trait RestaurantQueryHandler { /// Get the Restaurant view state by `id` async fn get_restaurant(&self, id: &str) -> Result, ErrorMessage>; @@ -47,7 +45,6 @@ pub trait RestaurantQueryHandler { } /// OrderQueryHandler trait - Query side of CQRS pattern -#[async_trait] pub trait OrderQueryHandler { /// Get the Order view state by `id` async fn get_order(&self, id: &str) -> Result, ErrorMessage>;