Skip to content

Commit

Permalink
remove postgres dependencies, cleanup remaining usages
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Sep 26, 2024
1 parent 2933630 commit 4789572
Show file tree
Hide file tree
Showing 18 changed files with 302 additions and 476 deletions.
128 changes: 1 addition & 127 deletions Cargo.lock

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

7 changes: 0 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ crates-index-diff = { version = "25.0.0", features = [ "max-performance" ]}
reqwest = { version = "0.12", features = ["json", "gzip"] }
semver = { version = "1.0.4", features = ["serde"] }
slug = "0.1.1"
r2d2 = "0.8"
r2d2_postgres = "0.18"
sqlx = { version = "0.8", features = [ "runtime-tokio", "postgres", "chrono" ] }
url = { version = "2.1.1", features = ["serde"] }
docsrs-metadata = { path = "crates/metadata" }
Expand All @@ -59,7 +57,6 @@ lol_html = "1.0.0"
font-awesome-as-a-crate = { path = "crates/font-awesome-as-a-crate" }
dashmap = "6.0.0"
string_cache = "0.8.0"
postgres-types = { version = "0.2", features = ["derive"] }
zip = {version = "2.2.0", default-features = false, features = ["bzip2"]}
bzip2 = "0.4.4"
getrandom = "0.2.1"
Expand Down Expand Up @@ -108,10 +105,6 @@ thread_local = "1.1.3"
humantime = "2.1.0"
constant_time_eq = "0.3.0"

[dependencies.postgres]
version = "0.19"
features = ["with-chrono-0_4", "with-serde_json-1"]

[target.'cfg(target_os = "linux")'.dependencies]
# Process information
procfs = "0.15.1"
Expand Down
37 changes: 19 additions & 18 deletions src/bin/cratesfyi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anyhow::{anyhow, Context as _, Error, Result};
use axum::async_trait;
use clap::{Parser, Subcommand, ValueEnum};
use docs_rs::cdn::CdnBackend;
use docs_rs::db::{self, add_path_into_database, Overrides, Pool, PoolClient};
use docs_rs::db::{self, add_path_into_database, Overrides, Pool};
use docs_rs::repositories::RepositoryStatsUpdater;
use docs_rs::utils::{
get_config, get_crate_pattern_and_priority, list_crate_priorities, queue_builder,
Expand Down Expand Up @@ -771,22 +771,27 @@ enum BlacklistSubcommand {

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

println!("{}", crates.join("\n"));
}
println!("{}", crates.join("\n"));
}

Self::Add { crate_name } => db::blacklist::add_crate(conn, &crate_name)
.context("failed to add crate to blacklist")?,
Self::Add { crate_name } => db::blacklist::add_crate(conn, &crate_name)
.await
.context("failed to add crate to blacklist")?,

Self::Remove { crate_name } => db::blacklist::remove_crate(conn, &crate_name)
.context("failed to remove crate from blacklist")?,
}
Ok(())
Self::Remove { crate_name } => db::blacklist::remove_crate(conn, &crate_name)
.await
.context("failed to remove crate from blacklist")?,
}
Ok(())
})
}
}

Expand Down Expand Up @@ -840,10 +845,6 @@ impl BinContext {
runtime: OnceCell::new(),
}
}

fn conn(&self) -> Result<PoolClient> {
Ok(self.pool()?.get()?)
}
}

macro_rules! lazy {
Expand Down
2 changes: 0 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ pub struct Config {

// Database connection params
pub(crate) database_url: String,
pub(crate) max_legacy_pool_size: u32,
pub(crate) max_pool_size: u32,
pub(crate) min_pool_idle: u32,

Expand Down Expand Up @@ -153,7 +152,6 @@ impl Config {
prefix: prefix.clone(),

database_url: require_env("DOCSRS_DATABASE_URL")?,
max_legacy_pool_size: env("DOCSRS_MAX_LEGACY_POOL_SIZE", 45)?,
max_pool_size: env("DOCSRS_MAX_POOL_SIZE", 45)?,
min_pool_idle: env("DOCSRS_MIN_POOL_IDLE", 10)?,

Expand Down
Loading

0 comments on commit 4789572

Please sign in to comment.