Skip to content

Commit 0c44456

Browse files
committed
migrate to a real connection pool for the sqlite connections
1 parent 673ffd8 commit 0c44456

File tree

6 files changed

+253
-83
lines changed

6 files changed

+253
-83
lines changed

Cargo.lock

+124-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ semver = { version = "1.0.4", features = ["serde"] }
3939
slug = "0.1.1"
4040
r2d2 = "0.8"
4141
r2d2_postgres = "0.18"
42+
r2d2_sqlite = "0.21.0"
4243
url = { version = "2.1.1", features = ["serde"] }
4344
docsrs-metadata = { path = "crates/metadata" }
4445
anyhow = { version = "1.0.42", features = ["backtrace"]}
@@ -70,7 +71,7 @@ serde_cbor = "0.11.1"
7071
getrandom = "0.2.1"
7172
itertools = { version = "0.10.5", optional = true}
7273
rusqlite = { version = "0.28.0", features = ["bundled"] }
73-
lru = "0.9.0"
74+
moka = { version ="0.10.0", default-features = false, features = ["sync"]}
7475

7576
# Async
7677
tokio = { version = "1.0", features = ["rt-multi-thread", "signal", "macros"] }

src/config.rs

+4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ pub struct Config {
1414
pub(crate) max_pool_size: u32,
1515
pub(crate) min_pool_idle: u32,
1616

17+
// local pool for sqlite connections
18+
pub(crate) max_sqlite_pool_size: u64,
19+
1720
// Storage params
1821
pub(crate) storage_backend: StorageKind,
1922

@@ -131,6 +134,7 @@ impl Config {
131134

132135
database_url: require_env("DOCSRS_DATABASE_URL")?,
133136
max_pool_size: env("DOCSRS_MAX_POOL_SIZE", 90)?,
137+
max_sqlite_pool_size: env("DOCSRS_MAX_SQLITE_POOL_SIZE", 500)?,
134138
min_pool_idle: env("DOCSRS_MIN_POOL_IDLE", 10)?,
135139

136140
storage_backend: env("DOCSRS_STORAGE_BACKEND", StorageKind::Database)?,

0 commit comments

Comments
 (0)