mirror of
https://gitlab.com/famedly/conduit.git
synced 2024-12-28 13:33:47 +03:00
feat: Add max prev events config option, allowing adjusting limit for prev_events fetching
This commit is contained in:
parent
c86313d4fa
commit
7c196f4e00
3 changed files with 11 additions and 1 deletions
|
@ -40,6 +40,8 @@ pub struct Config {
|
||||||
pub max_request_size: u32,
|
pub max_request_size: u32,
|
||||||
#[serde(default = "default_max_concurrent_requests")]
|
#[serde(default = "default_max_concurrent_requests")]
|
||||||
pub max_concurrent_requests: u16,
|
pub max_concurrent_requests: u16,
|
||||||
|
#[serde(default = "default_max_fetch_prev_events")]
|
||||||
|
pub max_fetch_prev_events: u16,
|
||||||
#[serde(default = "false_fn")]
|
#[serde(default = "false_fn")]
|
||||||
pub allow_registration: bool,
|
pub allow_registration: bool,
|
||||||
#[serde(default = "true_fn")]
|
#[serde(default = "true_fn")]
|
||||||
|
@ -249,6 +251,10 @@ fn default_max_concurrent_requests() -> u16 {
|
||||||
100
|
100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn default_max_fetch_prev_events() -> u16 {
|
||||||
|
100_u16
|
||||||
|
}
|
||||||
|
|
||||||
fn default_log() -> String {
|
fn default_log() -> String {
|
||||||
"warn,state_res=warn,_=off,sled=off".to_owned()
|
"warn,state_res=warn,_=off,sled=off".to_owned()
|
||||||
}
|
}
|
||||||
|
|
|
@ -222,6 +222,10 @@ impl Service {
|
||||||
self.config.max_request_size
|
self.config.max_request_size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn max_fetch_prev_events(&self) -> u16 {
|
||||||
|
self.config.max_fetch_prev_events
|
||||||
|
}
|
||||||
|
|
||||||
pub fn allow_registration(&self) -> bool {
|
pub fn allow_registration(&self) -> bool {
|
||||||
self.config.allow_registration
|
self.config.allow_registration
|
||||||
}
|
}
|
||||||
|
|
|
@ -1226,7 +1226,7 @@ impl Service {
|
||||||
.await
|
.await
|
||||||
.pop()
|
.pop()
|
||||||
{
|
{
|
||||||
if amount > 100 {
|
if amount > services().globals.max_fetch_prev_events() {
|
||||||
// Max limit reached
|
// Max limit reached
|
||||||
warn!("Max prev event limit reached!");
|
warn!("Max prev event limit reached!");
|
||||||
graph.insert(prev_event_id.clone(), HashSet::new());
|
graph.insert(prev_event_id.clone(), HashSet::new());
|
||||||
|
|
Loading…
Reference in a new issue