Skip to content

Commit 4789572

Browse files
committed
remove postgres dependencies, cleanup remaining usages
1 parent 2933630 commit 4789572

File tree

18 files changed

+302
-476
lines changed

18 files changed

+302
-476
lines changed

Cargo.lock

Lines changed: 1 addition & 127 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ crates-index-diff = { version = "25.0.0", features = [ "max-performance" ]}
3535
reqwest = { version = "0.12", features = ["json", "gzip"] }
3636
semver = { version = "1.0.4", features = ["serde"] }
3737
slug = "0.1.1"
38-
r2d2 = "0.8"
39-
r2d2_postgres = "0.18"
4038
sqlx = { version = "0.8", features = [ "runtime-tokio", "postgres", "chrono" ] }
4139
url = { version = "2.1.1", features = ["serde"] }
4240
docsrs-metadata = { path = "crates/metadata" }
@@ -59,7 +57,6 @@ lol_html = "1.0.0"
5957
font-awesome-as-a-crate = { path = "crates/font-awesome-as-a-crate" }
6058
dashmap = "6.0.0"
6159
string_cache = "0.8.0"
62-
postgres-types = { version = "0.2", features = ["derive"] }
6360
zip = {version = "2.2.0", default-features = false, features = ["bzip2"]}
6461
bzip2 = "0.4.4"
6562
getrandom = "0.2.1"
@@ -108,10 +105,6 @@ thread_local = "1.1.3"
108105
humantime = "2.1.0"
109106
constant_time_eq = "0.3.0"
110107

111-
[dependencies.postgres]
112-
version = "0.19"
113-
features = ["with-chrono-0_4", "with-serde_json-1"]
114-
115108
[target.'cfg(target_os = "linux")'.dependencies]
116109
# Process information
117110
procfs = "0.15.1"

src/bin/cratesfyi.rs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anyhow::{anyhow, Context as _, Error, Result};
99
use axum::async_trait;
1010
use clap::{Parser, Subcommand, ValueEnum};
1111
use docs_rs::cdn::CdnBackend;
12-
use docs_rs::db::{self, add_path_into_database, Overrides, Pool, PoolClient};
12+
use docs_rs::db::{self, add_path_into_database, Overrides, Pool};
1313
use docs_rs::repositories::RepositoryStatsUpdater;
1414
use docs_rs::utils::{
1515
get_config, get_crate_pattern_and_priority, list_crate_priorities, queue_builder,
@@ -771,22 +771,27 @@ enum BlacklistSubcommand {
771771

772772
impl BlacklistSubcommand {
773773
fn handle_args(self, ctx: BinContext) -> Result<()> {
774-
let conn = &mut *ctx.conn()?;
775-
match self {
776-
Self::List => {
777-
let crates = db::blacklist::list_crates(conn)
778-
.context("failed to list crates on blacklist")?;
774+
ctx.runtime()?.block_on(async {
775+
let conn = &mut *ctx.pool()?.get_async().await?;
776+
match self {
777+
Self::List => {
778+
let crates = db::blacklist::list_crates(conn)
779+
.await
780+
.context("failed to list crates on blacklist")?;
779781

780-
println!("{}", crates.join("\n"));
781-
}
782+
println!("{}", crates.join("\n"));
783+
}
782784

783-
Self::Add { crate_name } => db::blacklist::add_crate(conn, &crate_name)
784-
.context("failed to add crate to blacklist")?,
785+
Self::Add { crate_name } => db::blacklist::add_crate(conn, &crate_name)
786+
.await
787+
.context("failed to add crate to blacklist")?,
785788

786-
Self::Remove { crate_name } => db::blacklist::remove_crate(conn, &crate_name)
787-
.context("failed to remove crate from blacklist")?,
788-
}
789-
Ok(())
789+
Self::Remove { crate_name } => db::blacklist::remove_crate(conn, &crate_name)
790+
.await
791+
.context("failed to remove crate from blacklist")?,
792+
}
793+
Ok(())
794+
})
790795
}
791796
}
792797

@@ -840,10 +845,6 @@ impl BinContext {
840845
runtime: OnceCell::new(),
841846
}
842847
}
843-
844-
fn conn(&self) -> Result<PoolClient> {
845-
Ok(self.pool()?.get()?)
846-
}
847848
}
848849

849850
macro_rules! lazy {

src/config.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ pub struct Config {
1313

1414
// Database connection params
1515
pub(crate) database_url: String,
16-
pub(crate) max_legacy_pool_size: u32,
1716
pub(crate) max_pool_size: u32,
1817
pub(crate) min_pool_idle: u32,
1918

@@ -153,7 +152,6 @@ impl Config {
153152
prefix: prefix.clone(),
154153

155154
database_url: require_env("DOCSRS_DATABASE_URL")?,
156-
max_legacy_pool_size: env("DOCSRS_MAX_LEGACY_POOL_SIZE", 45)?,
157155
max_pool_size: env("DOCSRS_MAX_POOL_SIZE", 45)?,
158156
min_pool_idle: env("DOCSRS_MIN_POOL_IDLE", 10)?,
159157

0 commit comments

Comments
 (0)