Skip to content

Commit

Permalink
migrate to a real connection pool for the sqlite connections
Browse files Browse the repository at this point in the history
  • Loading branch information
syphar committed Mar 11, 2023
1 parent db17b5d commit 240be38
Show file tree
Hide file tree
Showing 6 changed files with 253 additions and 83 deletions.
134 changes: 124 additions & 10 deletions Cargo.lock

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

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ semver = { version = "1.0.4", features = ["serde"] }
slug = "0.1.1"
r2d2 = "0.8"
r2d2_postgres = "0.18"
r2d2_sqlite = "0.21.0"
url = { version = "2.1.1", features = ["serde"] }
docsrs-metadata = { path = "crates/metadata" }
anyhow = { version = "1.0.42", features = ["backtrace"]}
Expand Down Expand Up @@ -70,7 +71,7 @@ serde_cbor = "0.11.1"
getrandom = "0.2.1"
itertools = { version = "0.10.5", optional = true}
rusqlite = { version = "0.28.0", features = ["bundled"] }
lru = "0.9.0"
moka = { version ="0.10.0", default-features = false, features = ["sync"]}

# Async
tokio = { version = "1.0", features = ["rt-multi-thread", "signal", "macros"] }
Expand Down
4 changes: 4 additions & 0 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ pub struct Config {
pub(crate) max_pool_size: u32,
pub(crate) min_pool_idle: u32,

// local pool for sqlite connections
pub(crate) max_sqlite_pool_size: u64,

// Storage params
pub(crate) storage_backend: StorageKind,

Expand Down Expand Up @@ -126,6 +129,7 @@ impl Config {

database_url: require_env("DOCSRS_DATABASE_URL")?,
max_pool_size: env("DOCSRS_MAX_POOL_SIZE", 90)?,
max_sqlite_pool_size: env("DOCSRS_MAX_SQLITE_POOL_SIZE", 500)?,
min_pool_idle: env("DOCSRS_MIN_POOL_IDLE", 10)?,

storage_backend: env("DOCSRS_STORAGE_BACKEND", StorageKind::Database)?,
Expand Down
Loading

0 comments on commit 240be38

Please sign in to comment.