source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8"
-[[package]]
-name = "bb8"
-version = "0.8.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "1627eccf3aa91405435ba240be23513eeca466b5dc33866422672264de061582"
-dependencies = [
- "async-trait",
- "futures-channel",
- "futures-util",
- "parking_lot 0.12.1",
- "tokio",
-]
-
[[package]]
name = "bcrypt"
version = "0.13.0"
"parking_lot_core 0.9.4",
]
+[[package]]
+name = "deadpool"
+version = "0.9.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "421fe0f90f2ab22016f32a9881be5134fdd71c65298917084b0c7477cbc3856e"
+dependencies = [
+ "async-trait",
+ "deadpool-runtime",
+ "num_cpus",
+ "retain_mut",
+ "tokio",
+]
+
+[[package]]
+name = "deadpool-runtime"
+version = "0.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "eaa37046cc0f6c3cc6090fbdbf73ef0b8ef4cfcc37f6befc0020f63e8cf121e1"
+
[[package]]
name = "derive_builder"
version = "0.10.2"
checksum = "588383fa6d12fb17edf0fda88942222bbad070d185b5dcc3ac4d8354ce84b583"
dependencies = [
"async-trait",
- "bb8",
+ "deadpool",
"diesel",
"futures",
"tokio",
dependencies = [
"activitypub_federation",
"async-trait",
- "bb8",
"bcrypt",
"chrono",
"diesel",
"tracing-opentelemetry 0.16.0",
]
+[[package]]
+name = "retain_mut"
+version = "0.1.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "4389f1d5789befaf6029ebd9f7dac4af7f7e3d61b69d4f30e2ac02b57e7712b0"
+
[[package]]
name = "retry-policies"
version = "0.1.1"
[features]
full = ["diesel", "diesel-derive-newtype", "diesel_migrations", "bcrypt", "lemmy_utils",
"activitypub_federation", "sha2", "regex", "once_cell", "serde_json", "diesel_ltree",
- "diesel-async", "bb8"]
+ "diesel-async"]
[dependencies]
chrono = { workspace = true }
diesel = { workspace = true, features = ["postgres","chrono", "serde_json"], optional = true }
diesel-derive-newtype = { workspace = true, optional = true }
diesel_migrations = { workspace = true, optional = true }
-diesel-async = { workspace = true, features = ["postgres", "bb8"], optional = true }
+diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true }
sha2 = { workspace = true, optional = true }
regex = { workspace = true, optional = true }
once_cell = { workspace = true, optional = true }
typed-builder = { workspace = true }
async-trait = { workspace = true }
tokio = { workspace = true }
-bb8 = { version = "0.8.0", optional = true }
tracing = { workspace = true }
tracing-error = { workspace = true }
SortType,
};
use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject};
-use bb8::PooledConnection;
use chrono::NaiveDateTime;
use diesel::{
backend::Backend,
};
use diesel_async::{
pg::AsyncPgConnection,
- pooled_connection::{bb8::Pool, AsyncDieselConnectionManager},
+ pooled_connection::{
+ deadpool::{Object as PooledConnection, Pool},
+ AsyncDieselConnectionManager,
+ },
};
use diesel_migrations::EmbeddedMigrations;
use lemmy_utils::{error::LemmyError, settings::structs::Settings};
pub type DbPool = Pool<AsyncPgConnection>;
-pub async fn get_conn(
- pool: &DbPool,
-) -> Result<PooledConnection<AsyncDieselConnectionManager<AsyncPgConnection>>, DieselError> {
+pub async fn get_conn(pool: &DbPool) -> Result<PooledConnection<AsyncPgConnection>, DieselError> {
pool.get().await.map_err(|e| QueryBuilderError(e.into()))
}
let db_url = get_database_url(settings);
let pool_size = settings.map(|s| s.database.pool_size).unwrap_or(5);
let manager = AsyncDieselConnectionManager::<AsyncPgConnection>::new(&db_url);
- let pool = Pool::builder()
- .max_size(pool_size)
- .min_idle(Some(1))
- .build(manager)
- .await?;
+ let pool = Pool::builder(manager).max_size(pool_size).build()?;
// If there's no settings, that means its a unit test, and migrations need to be run
if settings.is_none() {
[dependencies]
lemmy_db_schema = { workspace = true }
diesel = { workspace = true, features = ["postgres","chrono","serde_json"], optional = true }
-diesel-async = { workspace = true, features = ["postgres", "bb8"], optional = true }
+diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true }
serde = { workspace = true }
typed-builder = { workspace = true }
[dependencies]
lemmy_db_schema = { workspace = true }
diesel = { workspace = true, features = ["postgres","chrono","serde_json"], optional = true }
-diesel-async = { workspace = true, features = ["postgres", "bb8"], optional = true }
+diesel-async = { workspace = true, features = ["postgres", "deadpool"], optional = true }
serde = { workspace = true }
pub(super) database: String,
/// Maximum number of active sql connections
#[default(5)]
- pub pool_size: u32,
+ pub pool_size: usize,
}
#[derive(Debug, Deserialize, Serialize, Clone, Document, SmartDefault)]
let settings = SETTINGS.to_owned();
- // Set up the bb8 connection pool
+ // Run the DB migrations
let db_url = get_database_url(Some(&settings));
run_migrations(&db_url);
- // Run the migrations from code
+ // Set up the connection pool
let pool = build_db_pool(&settings).await?;
+
+ // Run the Code-required migrations
run_advanced_migrations(&pool, &settings).await?;
// Initialize the secrets
use reqwest::Client;
#[tokio::test]
+ #[ignore]
async fn test_nodeinfo() {
let client = Client::builder().build().unwrap();
let lemmy_ml_nodeinfo = client