Skip to content

Commit

Permalink
removed async_trait in favour of Rust native async feature
Browse files Browse the repository at this point in the history
  • Loading branch information
idugalic committed Dec 31, 2023
1 parent af0bdc5 commit 4dcc81a
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 38 deletions.
22 changes: 16 additions & 6 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 0 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ authors = ["Ivan Dugalic <[email protected]>"]

[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"
Expand Down
2 changes: 0 additions & 2 deletions src/adapter/publisher/order_action_publisher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -12,7 +11,6 @@ pub struct OrderActionPublisher<'a> {
}

/// Fmodel action publisher implementation fot the OrderActionPublisher
#[async_trait]
impl ActionPublisher<OrderCommand, ErrorMessage> for OrderActionPublisher<'_> {
async fn publish(&self, commands: &[OrderCommand]) -> Result<Vec<OrderCommand>, ErrorMessage> {
for command in commands {
Expand Down
2 changes: 0 additions & 2 deletions src/adapter/repository/event_repository.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::adapter::repository::ToNewEventEntity;
use async_trait::async_trait;
use fmodel_rust::aggregate::EventRepository;
use uuid::Uuid;

Expand All @@ -22,7 +21,6 @@ impl AggregateEventRepository {
}

/// EventRepository - implementation of Fmodel EventRepository for Command, Event, Uuid, ErrorMessage
#[async_trait]
impl EventRepository<Command, Event, Uuid, ErrorMessage> for AggregateEventRepository {
async fn fetch_events(&self, command: &Command) -> Result<Vec<(Event, Uuid)>, ErrorMessage> {
// https://doc.rust-lang.org/rust-by-example/error/iter_result.html#fail-the-entire-operation-with-collect
Expand Down
2 changes: 0 additions & 2 deletions src/adapter/repository/order_event_repository.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::adapter::repository::ToNewEventEntity;
use async_trait::async_trait;
use fmodel_rust::aggregate::EventRepository;
use uuid::Uuid;

Expand All @@ -22,7 +21,6 @@ impl OrderEventRepository {
}

/// OrderEventRepository - implementation of Fmodel EventRepository for OrderCommand, OrderEvent, Uuid, ErrorMessage
#[async_trait]
impl EventRepository<OrderCommand, OrderEvent, Uuid, ErrorMessage> for OrderEventRepository {
async fn fetch_events(
&self,
Expand Down
4 changes: 0 additions & 4 deletions src/adapter/repository/order_view_state_repository.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use async_trait::async_trait;

use fmodel_rust::materialized_view::ViewStateRepository;

use crate::adapter::database::entity::OrderEntity;
Expand All @@ -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<Option<OrderViewState>, ErrorMessage> {
Expand All @@ -44,7 +41,6 @@ impl OrderQueryHandler for OrderViewStateRepository {
}

/// OrderViewStateRepository - implementation of Fmodel ViewStateRepository for OrderEvent, OrderViewState, ErrorMessage
#[async_trait]
impl ViewStateRepository<OrderEvent, Option<OrderViewState>, ErrorMessage>
for OrderViewStateRepository
{
Expand Down
2 changes: 0 additions & 2 deletions src/adapter/repository/restaurant_event_repository.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use crate::adapter::repository::ToNewEventEntity;
use async_trait::async_trait;
use fmodel_rust::aggregate::EventRepository;
use uuid::Uuid;

Expand All @@ -22,7 +21,6 @@ impl RestaurantEventRepository {
}

/// RestaurantEventRepository - implementation of Fmodel EventRepository for RestaurantCommand, RestaurantEvent, Uuid, ErrorMessage
#[async_trait]
impl EventRepository<RestaurantCommand, RestaurantEvent, Uuid, ErrorMessage>
for RestaurantEventRepository
{
Expand Down
4 changes: 0 additions & 4 deletions src/adapter/repository/restaurant_view_state_repository.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use async_trait::async_trait;

use fmodel_rust::materialized_view::ViewStateRepository;

use crate::adapter::database::entity::RestaurantEntity;
Expand All @@ -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<Option<RestaurantViewState>, ErrorMessage> {
Expand All @@ -44,7 +41,6 @@ impl RestaurantQueryHandler for RestaurantViewStateRepository {
}

/// RestaurantViewStateRepository - implementation of Fmodel ViewStateRepository for RestaurantEvent, RestaurantViewState, ErrorMessage
#[async_trait]
impl ViewStateRepository<RestaurantEvent, Option<RestaurantViewState>, ErrorMessage>
for RestaurantViewStateRepository
{
Expand Down
3 changes: 0 additions & 3 deletions src/application/api.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Option<RestaurantViewState>, ErrorMessage>;
Expand All @@ -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<Option<OrderViewState>, ErrorMessage>;
Expand Down

0 comments on commit 4dcc81a

Please sign in to comment.