mirror of https://github.com/LemmyNet/lemmy.git
Moving retry_limit to settings
parent
31cd4edc2c
commit
e2709f6967
|
@ -111,4 +111,6 @@
|
|||
slur_filter: "(\bThis\b)|(\bis\b)|(\bsample\b)"
|
||||
# Maximum length of local community and user names
|
||||
actor_name_max_length: 20
|
||||
# Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
|
||||
http_fetch_retry_limit: 25
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ use lemmy_apub_lib::{
|
|||
};
|
||||
use lemmy_db_schema::newtypes::DbUrl;
|
||||
use lemmy_utils::{
|
||||
request::{retry, RecvError, RETRY_LIMIT},
|
||||
request::{retry, RecvError},
|
||||
LemmyError,
|
||||
};
|
||||
use lemmy_websocket::LemmyContext;
|
||||
|
@ -82,7 +82,7 @@ where
|
|||
debug!("Fetching webfinger url: {}", &fetch_url);
|
||||
|
||||
*request_counter += 1;
|
||||
if *request_counter > RETRY_LIMIT {
|
||||
if *request_counter > context.settings().http_fetch_retry_limit {
|
||||
return Err(LemmyError::from(anyhow!("Request retry limit reached")));
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ use activitystreams::chrono::{Duration as ChronoDuration, NaiveDateTime, Utc};
|
|||
use anyhow::anyhow;
|
||||
use diesel::NotFound;
|
||||
use lemmy_utils::{
|
||||
request::{build_user_agent, retry, RETRY_LIMIT},
|
||||
request::{build_user_agent, retry},
|
||||
settings::structs::Settings,
|
||||
LemmyError,
|
||||
};
|
||||
|
@ -115,7 +115,7 @@ where
|
|||
info!("Fetching remote object {}", self.to_string());
|
||||
|
||||
*request_counter += 1;
|
||||
if *request_counter > RETRY_LIMIT {
|
||||
if *request_counter > Settings::get().http_fetch_retry_limit {
|
||||
return Err(LemmyError::from(anyhow!("Request retry limit reached")));
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,6 @@ struct SendError(pub String);
|
|||
#[error("Error receiving response, {0}")]
|
||||
pub struct RecvError(pub String);
|
||||
|
||||
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object
|
||||
/// fetch through the search). This should be configurable.
|
||||
pub static RETRY_LIMIT: i32 = 25;
|
||||
|
||||
pub async fn retry<F, Fut, T>(f: F) -> Result<T, reqwest::Error>
|
||||
where
|
||||
F: Fn() -> Fut,
|
||||
|
|
|
@ -46,6 +46,9 @@ pub struct Settings {
|
|||
/// Maximum length of local community and user names
|
||||
#[default(20)]
|
||||
pub actor_name_max_length: usize,
|
||||
/// Maximum number of HTTP requests allowed to handle a single incoming activity (or a single object fetch through the search).
|
||||
#[default(25)]
|
||||
pub http_fetch_retry_limit: i32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, Clone, SmartDefault, Document)]
|
||||
|
|
Loading…
Reference in New Issue