Add federation.fetcher_timeout and federation.deliverer_timeout configuration parameters
This commit is contained in:
parent
378d94e7b8
commit
dd0c53c5e9
5 changed files with 22 additions and 6 deletions
|
@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||||
- Added `prune-remote-emojis` command.
|
- Added `prune-remote-emojis` command.
|
||||||
- Prune remote emojis in background.
|
- Prune remote emojis in background.
|
||||||
- Added `limits.media.emoji_size_limit` configuration parameter.
|
- Added `limits.media.emoji_size_limit` configuration parameter.
|
||||||
|
- Added `federation.fetcher_timeout` and `federation.deliverer_timeout` configuration parameters.
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,8 @@ impl Config {
|
||||||
is_private:
|
is_private:
|
||||||
!self.federation.enabled ||
|
!self.federation.enabled ||
|
||||||
matches!(self.environment, Environment::Development),
|
matches!(self.environment, Environment::Development),
|
||||||
|
fetcher_timeout: self.federation.fetcher_timeout,
|
||||||
|
deliverer_timeout: self.federation.deliverer_timeout,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,6 +140,8 @@ pub struct Instance {
|
||||||
pub onion_proxy_url: Option<String>,
|
pub onion_proxy_url: Option<String>,
|
||||||
// Private instance won't send signed HTTP requests
|
// Private instance won't send signed HTTP requests
|
||||||
pub is_private: bool,
|
pub is_private: bool,
|
||||||
|
pub fetcher_timeout: u64,
|
||||||
|
pub deliverer_timeout: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Instance {
|
impl Instance {
|
||||||
|
@ -168,6 +172,8 @@ impl Instance {
|
||||||
proxy_url: None,
|
proxy_url: None,
|
||||||
onion_proxy_url: None,
|
onion_proxy_url: None,
|
||||||
is_private: true,
|
is_private: true,
|
||||||
|
fetcher_timeout: 0,
|
||||||
|
deliverer_timeout: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -187,6 +193,8 @@ mod tests {
|
||||||
proxy_url: None,
|
proxy_url: None,
|
||||||
onion_proxy_url: None,
|
onion_proxy_url: None,
|
||||||
is_private: true,
|
is_private: true,
|
||||||
|
fetcher_timeout: 0,
|
||||||
|
deliverer_timeout: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(instance.url(), "https://example.com");
|
assert_eq!(instance.url(), "https://example.com");
|
||||||
|
@ -207,6 +215,8 @@ mod tests {
|
||||||
proxy_url: None,
|
proxy_url: None,
|
||||||
onion_proxy_url: None,
|
onion_proxy_url: None,
|
||||||
is_private: true,
|
is_private: true,
|
||||||
|
fetcher_timeout: 0,
|
||||||
|
deliverer_timeout: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
assert_eq!(instance.url(), "http://1.2.3.4:3777");
|
assert_eq!(instance.url(), "http://1.2.3.4:3777");
|
||||||
|
|
|
@ -2,10 +2,17 @@ use serde::Deserialize;
|
||||||
|
|
||||||
fn default_federation_enabled() -> bool { true }
|
fn default_federation_enabled() -> bool { true }
|
||||||
|
|
||||||
|
const fn default_fetcher_timeout() -> u64 { 300 }
|
||||||
|
const fn default_deliverer_timeout() -> u64 { 30 }
|
||||||
|
|
||||||
#[derive(Clone, Deserialize)]
|
#[derive(Clone, Deserialize)]
|
||||||
pub struct FederationConfig {
|
pub struct FederationConfig {
|
||||||
#[serde(default = "default_federation_enabled")]
|
#[serde(default = "default_federation_enabled")]
|
||||||
pub enabled: bool,
|
pub enabled: bool,
|
||||||
|
#[serde(default = "default_fetcher_timeout")]
|
||||||
|
pub(super) fetcher_timeout: u64,
|
||||||
|
#[serde(default = "default_deliverer_timeout")]
|
||||||
|
pub(super) deliverer_timeout: u64,
|
||||||
pub(super) proxy_url: Option<String>,
|
pub(super) proxy_url: Option<String>,
|
||||||
pub(super) onion_proxy_url: Option<String>,
|
pub(super) onion_proxy_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
@ -14,6 +21,8 @@ impl Default for FederationConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
enabled: default_federation_enabled(),
|
enabled: default_federation_enabled(),
|
||||||
|
fetcher_timeout: default_fetcher_timeout(),
|
||||||
|
deliverer_timeout: default_deliverer_timeout(),
|
||||||
proxy_url: None,
|
proxy_url: None,
|
||||||
onion_proxy_url: None,
|
onion_proxy_url: None,
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,8 +36,6 @@ use super::{
|
||||||
queues::OutgoingActivityJobData,
|
queues::OutgoingActivityJobData,
|
||||||
};
|
};
|
||||||
|
|
||||||
const DELIVERER_TIMEOUT: u64 = 30;
|
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum DelivererError {
|
pub enum DelivererError {
|
||||||
#[error("key error")]
|
#[error("key error")]
|
||||||
|
@ -71,7 +69,7 @@ fn build_client(
|
||||||
let client = build_federation_client(
|
let client = build_federation_client(
|
||||||
instance,
|
instance,
|
||||||
is_onion,
|
is_onion,
|
||||||
DELIVERER_TIMEOUT,
|
instance.deliverer_timeout,
|
||||||
)?;
|
)?;
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,6 @@ use crate::http_signatures::create::{
|
||||||
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
use crate::media::{save_file, SUPPORTED_MEDIA_TYPES};
|
||||||
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
|
use crate::webfinger::types::{ActorAddress, JsonResourceDescriptor};
|
||||||
|
|
||||||
const FETCHER_TIMEOUT: u64 = 180;
|
|
||||||
|
|
||||||
#[derive(thiserror::Error, Debug)]
|
#[derive(thiserror::Error, Debug)]
|
||||||
pub enum FetchError {
|
pub enum FetchError {
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
|
@ -62,7 +60,7 @@ fn build_client(
|
||||||
let client = build_federation_client(
|
let client = build_federation_client(
|
||||||
instance,
|
instance,
|
||||||
is_onion,
|
is_onion,
|
||||||
FETCHER_TIMEOUT,
|
instance.fetcher_timeout,
|
||||||
)?;
|
)?;
|
||||||
Ok(client)
|
Ok(client)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue