Skip to content

Commit

Permalink
fix: Remove direct dependency on deadpool-postgres and tokio-postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
jacobsvante committed Jan 8, 2025
1 parent c2e97bf commit 6aca315
Show file tree
Hide file tree
Showing 14 changed files with 16 additions and 21 deletions.
2 changes: 0 additions & 2 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions samling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ base64 = "0.22.1"
bytes = { version = "1.9.0", features = ["serde"] }
clap = { version = "4.5.24", features = ["derive", "env"], optional = true }
csv = "1.3.1"
deadpool-postgres = "0.14.1"
derive_more = { version = "1.0.0", features = ["full"] }
dotenvy = "0.15.7"
futures = "0.3.31"
Expand Down Expand Up @@ -82,7 +81,6 @@ tokio = { version = "1.42.0", default-features = false, features = [
"macros",
"rt-multi-thread",
] }
tokio-postgres = "0.7.12"
tower = "0.5.2"
tower-http = { version = "0.6.2", default-features = false, features = [
"fs",
Expand Down
3 changes: 1 addition & 2 deletions samling/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::net::SocketAddr;
use axum::extract::{DefaultBodyLimit, State};
use axum::http::Method;
use axum::Json;
use deadpool_postgres::Pool;
use http::header::{AUTHORIZATION, CONTENT_DISPOSITION, CONTENT_TYPE};
use http::HeaderValue;
use tokio::net::TcpListener;
Expand All @@ -13,9 +12,9 @@ use tower_http::trace::TraceLayer;

use crate::auth::hashing::Hasher;
use crate::auth::signing::JwtSigner;

use crate::cloudflare::CloudflareApi;
use crate::db_migrations::Migrator;
use crate::deadpool_postgres::Pool;
use crate::errors::{CliResult, Result};
use crate::routes::AppRouter;
use crate::state::AppState;
Expand Down
2 changes: 1 addition & 1 deletion samling/src/attributes/repo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use deadpool_postgres::Object;
use crate::deadpool_postgres::Object;
use samling_clorinde::client::{GenericClient, Params};

use super::{
Expand Down
2 changes: 1 addition & 1 deletion samling/src/auth/repo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use deadpool_postgres::Object;
use futures::future::try_join_all;
use itertools::Itertools;
use password_hash::PasswordHashString;
Expand All @@ -8,6 +7,7 @@ use serde::Deserialize;
use super::{
filters::UserFilters, hashing::Hasher, sorting::UserSortOrder, CreateUser, UpdateUser, User,
};
use crate::deadpool_postgres::Object;
use crate::{
entity_ref::{Id, RefType},
organizations::Organization,
Expand Down
2 changes: 1 addition & 1 deletion samling/src/collections/repo.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use deadpool_postgres::Object;
use futures::{future::try_join_all, try_join};
use itertools::Itertools;

use super::{Collection, CreateCollection, UpdateCollection};
use crate::deadpool_postgres::Object;
use crate::{
entity_ref::{ExternalIdEntity, Id, RefTarget, SlugEntity},
organizations::Organization,
Expand Down
4 changes: 2 additions & 2 deletions samling/src/db_migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ use include_dir::{include_dir, Dir};

static MIGRATIONS: Dir<'_> = include_dir!("$CARGO_MANIFEST_DIR/migrations");

use deadpool_postgres::Pool;
use serde::Serialize;
use tokio::sync::Mutex;
use tokio_postgres::error::SqlState;
use tracing::log::{debug, info};

use crate::deadpool_postgres::Pool;
use crate::tokio_postgres::error::SqlState;
use crate::Result;
use samling_clorinde::queries::misc::{migrate_revision, set_migrate_revision};

Expand Down
3 changes: 2 additions & 1 deletion samling/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use schemars::JsonSchema;
use serde::Serialize;

use crate::auth::rbac::Permission;
use crate::deadpool_postgres;

pub type Result<T> = std::result::Result<T, Error>;

Expand Down Expand Up @@ -68,7 +69,7 @@ pub enum Error {
#[error("Invalid header error: {0}")]
InvalidHttpHeaderValue(#[from] http::header::InvalidHeaderValue),
#[error("tokio-postgres error: {0}")]
DbError(#[from] tokio_postgres::Error),
DbError(#[from] crate::tokio_postgres::Error),
#[error("Deadpool pool error: {0}")]
DbPoolError(#[from] deadpool_postgres::PoolError),
#[error("Deadpool create pool error: {0}")]
Expand Down
2 changes: 1 addition & 1 deletion samling/src/extractors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use axum::{
extract::{FromRequestParts, Query},
RequestPartsExt,
};
use deadpool_postgres::Object;
use http::request::Parts;
use serde::Deserialize;

use crate::deadpool_postgres::Object;
use crate::{helpers, state::AppState, Error, Result};

pub(crate) struct PoolClient(pub(crate) Object);
Expand Down
4 changes: 2 additions & 2 deletions samling/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use deadpool_postgres::{Pool, Timeouts};
use serde::{
de::{self, Deserialize, Deserializer, Visitor},
forward_to_deserialize_any,
};

use crate::deadpool_postgres::{self, Pool, Timeouts};
use crate::Result;

pub fn create_deadpool_manager(
Expand All @@ -21,7 +21,7 @@ pub fn create_deadpool_manager(
cfg.port = Some(db_port);
cfg.dbname = Some(db_name);
let builder = cfg
.builder(tokio_postgres::NoTls)
.builder(crate::tokio_postgres::NoTls)
.unwrap()
.max_size(max_db_connections as usize) // TODO: Do these really correspond?
.timeouts(Timeouts::wait_millis(30_000))
Expand Down
4 changes: 2 additions & 2 deletions samling/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ mod ui;
pub use errors::*;

pub mod deadpool_postgres {
pub use deadpool_postgres::*;
pub use samling_clorinde::deadpool_postgres::*;
}

pub mod tokio_postgres {
pub use tokio_postgres::*;
pub use samling_clorinde::tokio_postgres::*;
}
3 changes: 1 addition & 2 deletions samling/src/prices/repo.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
use deadpool_postgres::Object;

use samling_clorinde::{
client::{GenericClient, Params},
queries::{
Expand All @@ -19,6 +17,7 @@ use samling_clorinde::{
};

use super::{CreatePrice, CreatePriceList, Price, PriceList, UpdatePrice, UpdatePriceList};
use crate::deadpool_postgres::Object;
use crate::{
auth::User,
entity_ref::{ExternalIdEntity, Id, RefTarget},
Expand Down
2 changes: 1 addition & 1 deletion samling/src/state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use axum::extract::FromRef;
use deadpool_postgres::Pool;

use crate::deadpool_postgres::Pool;
use crate::{db_migrations::Migrator, hashing::Hasher, CloudflareApi, Environment, JwtSigner};

#[derive(Debug, Clone, FromRef)]
Expand Down
2 changes: 1 addition & 1 deletion samling/src/styles/repo.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
use deadpool_postgres::Object;
use futures::future::{try_join, try_join_all};
use itertools::Itertools;
use samling_clorinde::client::{GenericClient, Params};

use super::{CreateStyle, Style, UpdateStyle};
use crate::auth::User;
use crate::deadpool_postgres::Object;
use crate::entity_ref::{ExternalIdEntity, Id, Ref, RefTarget, RefType, SlugEntity};
use crate::organizations::Organization;
use crate::sorting::Sortable;
Expand Down

0 comments on commit 6aca315

Please sign in to comment.