Skip to content

Commit

Permalink
Add DB settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cetra3 committed Jun 19, 2023
1 parent 723e023 commit be5e000
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/api_common/src/site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ pub struct CreateSite {
pub federation_enabled: Option<bool>,
pub federation_debug: Option<bool>,
pub federation_worker_count: Option<i32>,
pub federation_worker_retry_count: Option<i32>,
pub captcha_enabled: Option<bool>,
pub captcha_difficulty: Option<String>,
pub allowed_instances: Option<Vec<String>>,
Expand Down Expand Up @@ -252,6 +253,8 @@ pub struct EditSite {
pub federation_debug: Option<bool>,
/// The number of federation workers.
pub federation_worker_count: Option<i32>,
/// The number of federation retry workers.
pub federation_worker_retry_count: Option<i32>,
/// Whether to enable captchas for signups.
pub captcha_enabled: Option<bool>,
/// The captcha difficulty. Can be easy, medium, or hard
Expand Down
1 change: 1 addition & 0 deletions crates/api_crud/src/site/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ impl PerformCrud for EditSite {
.actor_name_max_length(data.actor_name_max_length)
.federation_enabled(data.federation_enabled)
.federation_worker_count(data.federation_worker_count)
.federation_worker_retry_count(data.federation_worker_retry_count)
.captcha_enabled(data.captcha_enabled)
.captcha_difficulty(data.captcha_difficulty.clone())
.reports_email_admins(data.reports_email_admins)
Expand Down
1 change: 1 addition & 0 deletions crates/db_schema/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ diesel::table! {
updated -> Nullable<Timestamp>,
registration_mode -> RegistrationModeEnum,
reports_email_admins -> Bool,
federation_worker_retry_count -> Int4,
}
}

Expand Down
4 changes: 4 additions & 0 deletions crates/db_schema/src/source/local_site.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ pub struct LocalSite {
pub registration_mode: RegistrationMode,
/// Whether to email admins on new reports.
pub reports_email_admins: bool,
/// The number of concurrent federation retry http workers.
pub federation_worker_retry_count: i32,
}

#[derive(Clone, TypedBuilder)]
Expand Down Expand Up @@ -90,6 +92,7 @@ pub struct LocalSiteInsertForm {
pub captcha_difficulty: Option<String>,
pub registration_mode: Option<RegistrationMode>,
pub reports_email_admins: Option<bool>,
pub federation_worker_retry_count: Option<i32>,
}

#[derive(Clone, TypedBuilder)]
Expand Down Expand Up @@ -118,4 +121,5 @@ pub struct LocalSiteUpdateForm {
pub registration_mode: Option<RegistrationMode>,
pub reports_email_admins: Option<bool>,
pub updated: Option<Option<chrono::NaiveDateTime>>,
pub federation_worker_retry_count: Option<i32>,
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alter table local_site drop column federation_worker_retry_count;
2 changes: 2 additions & 0 deletions migrations/2023-06-19-055530_add_retry_worker_setting/up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table local_site add column
federation_worker_retry_count int default 128 not null;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub async fn start_lemmy_server() -> Result<(), LemmyError> {
.client(client.clone())
.http_fetch_limit(FEDERATION_HTTP_FETCH_LIMIT)
.worker_count(local_site.federation_worker_count as usize)
.retry_count(local_site.federation_worker_retry_count as usize)
.debug(cfg!(debug_assertions))
.http_signature_compat(true)
.url_verifier(Box::new(VerifyUrlData(context.pool().clone())))
Expand Down

0 comments on commit be5e000

Please sign in to comment.