#768 Make database connections configurable by environment variables

Merged KitaitiMakoto
Coverage Reach
plume-models/src/timeline/mod.rs plume-models/src/timeline/query.rs plume-models/src/users.rs plume-models/src/blogs.rs plume-models/src/posts.rs plume-models/src/search/query.rs plume-models/src/search/searcher.rs plume-models/src/search/mod.rs plume-models/src/search/tokenizer.rs plume-models/src/instance.rs plume-models/src/lists.rs plume-models/src/comments.rs plume-models/src/inbox.rs plume-models/src/medias.rs plume-models/src/follows.rs plume-models/src/lib.rs plume-models/src/notifications.rs plume-models/src/reshares.rs plume-models/src/likes.rs plume-models/src/config.rs plume-models/src/password_reset_requests.rs plume-models/src/mentions.rs plume-models/src/blocklisted_emails.rs plume-models/src/safe_string.rs plume-models/src/migrations.rs plume-models/src/api_tokens.rs plume-models/src/tags.rs plume-models/src/plume_rocket.rs plume-models/src/db_conn.rs plume-models/src/comment_seers.rs plume-models/src/headers.rs plume-models/src/admin.rs plume-models/src/apps.rs plume-models/src/blog_authors.rs plume-models/src/post_authors.rs src/routes/user.rs src/routes/posts.rs src/routes/instance.rs src/routes/blogs.rs src/routes/session.rs src/routes/mod.rs src/routes/comments.rs src/routes/medias.rs src/routes/well_known.rs src/routes/likes.rs src/routes/reshares.rs src/routes/search.rs src/routes/errors.rs src/routes/timelines.rs src/routes/notifications.rs src/routes/tags.rs src/api/posts.rs src/api/mod.rs src/api/apps.rs src/api/authorization.rs src/template_utils.rs src/main.rs src/inbox.rs src/mail.rs src/test_routes.rs plume-common/src/activity_pub/inbox.rs plume-common/src/activity_pub/sign.rs plume-common/src/activity_pub/mod.rs plume-common/src/activity_pub/request.rs plume-common/src/utils.rs plume-cli/src/users.rs plume-cli/src/search.rs plume-cli/src/main.rs plume-cli/src/instance.rs plume-cli/src/migration.rs plume-macro/src/lib.rs plume-api/src/posts.rs plume-api/src/apps.rs

Flags

Flags have been temporarily removed from this view while the flagging feature is refactored for better performance and user experience.

You can still use flags when viewing individual files. Flag-level thresholds will also remain on pull and merge requests in your repository provider.

More information can be found in our documentation.


@@ -55,10 +55,13 @@
Loading
55 55
    }
56 56
57 57
    let manager = ConnectionManager::<Connection>::new(CONFIG.database_url.as_str());
58 -
    let pool = DbPool::builder()
58 +
    let mut builder = DbPool::builder()
59 59
        .connection_customizer(Box::new(PragmaForeignKey))
60 -
        .build(manager)
61 -
        .ok()?;
60 +
        .min_idle(CONFIG.db_min_idle);
61 +
    if let Some(max_size) = CONFIG.db_max_size {
62 +
        builder = builder.max_size(max_size);
63 +
    };
64 +
    let pool = builder.build(manager).ok()?;
62 65
    Instance::cache_local(&pool.get().unwrap());
63 66
    Some(pool)
64 67
}

@@ -11,6 +11,8 @@
Loading
11 11
    pub base_url: String,
12 12
    pub database_url: String,
13 13
    pub db_name: &'static str,
14 +
    pub db_max_size: Option<u32>,
15 +
    pub db_min_idle: Option<u32>,
14 16
    pub search_index: String,
15 17
    pub rocket: Result<RocketConfig, RocketError>,
16 18
    pub logo: LogoConfig,
@@ -193,6 +195,14 @@
Loading
193 195
            var("ROCKET_PORT").unwrap_or_else(|_| "7878".to_owned())
194 196
        )),
195 197
        db_name: DB_NAME,
198 +
        db_max_size: var("DB_MAX_SIZE").map_or(None, |s| Some(
199 +
            s.parse::<u32>()
200 +
                .expect("Couldn't parse DB_MAX_SIZE into u32")
201 +
        )),
202 +
        db_min_idle: var("DB_MIN_IDLE").map_or(None, |s| Some(
203 +
            s.parse::<u32>()
204 +
                .expect("Couldn't parse DB_MIN_IDLE into u32")
205 +
        )),
196 206
        #[cfg(feature = "postgres")]
197 207
        database_url: var("DATABASE_URL")
198 208
            .unwrap_or_else(|_| format!("postgres://plume:plume@localhost/{}", DB_NAME)),

Everything is accounted for!

No changes detected that need to be reviewed.
What changes does Codecov check for?
Lines, not adjusted in diff, that have changed coverage data.
Files that introduced coverage data that had none before.
Files that have missing coverage data that once were tracked.
Files Coverage
plume-api/src 0.00%
plume-cli/src 60.88%
plume-common/src 45.26%
plume-models/src -0.06% 53.54%
src -0.01% 3.97%
plume-macro/src/lib.rs 55.55%
Project Totals (73 files) 38.96%
Loading