Skip to content

Commit

Permalink
chore: Remove async-trait
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernauer committed Jan 15, 2024
1 parent 5ff113a commit 345de4e
Show file tree
Hide file tree
Showing 15 changed files with 55 additions and 66 deletions.
93 changes: 51 additions & 42 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ edition = "2021"
repository = "https://github.com/stackabletech/trino-lb"

[workspace.dependencies]
async-trait = "0.1"
axum = { version = "0.7", features = ["tracing"] }
axum-server = { version = "0.6", features = ["tls-rustls"] }
bincode = "1.3"
Expand Down Expand Up @@ -51,6 +50,7 @@ tower = "0.4"
tracing = "0.1"
tracing-opentelemetry = "0.22"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
trait-variant = "0.1"
url = { version = "2.5", features = ["serde"] }

# For trino-lb-bench
Expand Down
1 change: 0 additions & 1 deletion trino-lb-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ repository.workspace = true
publish = false

[dependencies]
async-trait.workspace = true
chrono.workspace = true
http-serde.workspace = true
http.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion trino-lb-persistence/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ publish = false
[dependencies]
trino-lb-core = { path = "../trino-lb-core" }

async-trait.workspace = true
bincode.workspace = true
enum_dispatch.workspace = true
futures.workspace = true
Expand All @@ -24,4 +23,5 @@ snafu.workspace = true
sqlx.workspace = true
tokio.workspace = true
tracing.workspace = true
trait-variant.workspace = true
url.workspace = true
2 changes: 0 additions & 2 deletions trino-lb-persistence/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use std::{
time::{Duration, SystemTime, SystemTimeError, UNIX_EPOCH},
};

use async_trait::async_trait;
use snafu::{OptionExt, ResultExt, Snafu};
use tokio::sync::RwLock;
use tracing::{error, info, instrument};
Expand Down Expand Up @@ -54,7 +53,6 @@ impl Default for InMemoryPersistence {
}
}

#[async_trait]
impl Persistence for InMemoryPersistence {
#[instrument(skip(self))]
async fn store_queued_query(&self, queued_query: QueuedQuery) -> Result<(), super::Error> {
Expand Down
4 changes: 2 additions & 2 deletions trino-lb-persistence/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::{fmt::Debug, time::SystemTime};

use async_trait::async_trait;
use enum_dispatch::enum_dispatch;
use snafu::Snafu;
use trino_lb_core::{
Expand Down Expand Up @@ -29,8 +28,9 @@ pub enum Error {
/// multiple replicas of trino-lb and every instance can answer requests for every query correctly. This is especially important
/// for increment and decrement operations to not end up with a wrong query count after multiple trino-lb instances modifying the
/// counter simultaneous.
#[async_trait]
#[enum_dispatch(PersistenceImplementation)]
// According to https://blog.rust-lang.org/2023/12/21/async-fn-rpit-in-traits.html
#[trait_variant::make(SendPersistence: Send)]
pub trait Persistence {
async fn store_queued_query(&self, query: QueuedQuery) -> Result<(), Error>;
async fn load_queued_query(&self, query_id: &TrinoLbQueryId) -> Result<QueuedQuery, Error>;
Expand Down
2 changes: 0 additions & 2 deletions trino-lb-persistence/src/postgres/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};

use async_trait::async_trait;
use http::HeaderMap;
use serde::{Deserialize, Serialize};
use snafu::{ResultExt, Snafu};
Expand Down Expand Up @@ -135,7 +134,6 @@ struct HeaderMapWrapper {
pub inner: HeaderMap,
}

#[async_trait]
impl Persistence for PostgresPersistence {
#[instrument(skip(self))]
async fn store_queued_query(&self, queued_query: QueuedQuery) -> Result<(), super::Error> {
Expand Down
2 changes: 0 additions & 2 deletions trino-lb-persistence/src/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ use std::{
time::{Duration, SystemTime, SystemTimeError, UNIX_EPOCH},
};

use async_trait::async_trait;
use futures::{future::try_join_all, TryFutureExt};
use redis::{
cluster::ClusterClientBuilder, cluster_async::ClusterConnection, AsyncCommands, RedisError,
Expand Down Expand Up @@ -161,7 +160,6 @@ impl RedisPersistence {
}
}

#[async_trait]
impl Persistence for RedisPersistence {
#[instrument(skip(self))]
async fn store_queued_query(&self, queued_query: QueuedQuery) -> Result<(), super::Error> {
Expand Down
1 change: 0 additions & 1 deletion trino-lb/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ default-run = "trino-lb"
trino-lb-core = { path = "../trino-lb-core" }
trino-lb-persistence = { path = "../trino-lb-persistence" }

async-trait.workspace = true
axum-server.workspace = true
axum.workspace = true
chrono.workspace = true
Expand Down
Loading

0 comments on commit 345de4e

Please sign in to comment.