add conf item to toggle startup netburst (for developers).
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
3cf67f3993
commit
125ff21c88
2 changed files with 24 additions and 16 deletions
|
@ -226,6 +226,9 @@ pub struct Config {
|
||||||
#[serde(with = "serde_regex")]
|
#[serde(with = "serde_regex")]
|
||||||
pub forbidden_usernames: RegexSet,
|
pub forbidden_usernames: RegexSet,
|
||||||
|
|
||||||
|
#[serde(default = "default_startup_netburst")]
|
||||||
|
pub startup_netburst: bool,
|
||||||
|
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub block_non_admin_invites: bool,
|
pub block_non_admin_invites: bool,
|
||||||
|
|
||||||
|
@ -518,6 +521,7 @@ impl fmt::Display for Config {
|
||||||
"Allow check for updates / announcements check",
|
"Allow check for updates / announcements check",
|
||||||
&self.allow_check_for_updates.to_string(),
|
&self.allow_check_for_updates.to_string(),
|
||||||
),
|
),
|
||||||
|
("Enable netburst on startup", &self.startup_netburst.to_string()),
|
||||||
];
|
];
|
||||||
|
|
||||||
let mut msg: String = "Active config values:\n\n".to_owned();
|
let mut msg: String = "Active config values:\n\n".to_owned();
|
||||||
|
@ -675,3 +679,5 @@ fn default_url_preview_max_spider_size() -> usize {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn default_new_user_displayname_suffix() -> String { "🏳️⚧️".to_owned() }
|
fn default_new_user_displayname_suffix() -> String { "🏳️⚧️".to_owned() }
|
||||||
|
|
||||||
|
fn default_startup_netburst() -> bool { true }
|
||||||
|
|
|
@ -90,6 +90,7 @@ pub struct Service {
|
||||||
pub(super) maximum_requests: Arc<Semaphore>,
|
pub(super) maximum_requests: Arc<Semaphore>,
|
||||||
pub sender: mpsc::UnboundedSender<(OutgoingKind, SendingEventType, Vec<u8>)>,
|
pub sender: mpsc::UnboundedSender<(OutgoingKind, SendingEventType, Vec<u8>)>,
|
||||||
receiver: Mutex<mpsc::UnboundedReceiver<(OutgoingKind, SendingEventType, Vec<u8>)>>,
|
receiver: Mutex<mpsc::UnboundedReceiver<(OutgoingKind, SendingEventType, Vec<u8>)>>,
|
||||||
|
startup_netburst: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum TransactionStatus {
|
enum TransactionStatus {
|
||||||
|
@ -106,6 +107,7 @@ impl Service {
|
||||||
sender,
|
sender,
|
||||||
receiver: Mutex::new(receiver),
|
receiver: Mutex::new(receiver),
|
||||||
maximum_requests: Arc::new(Semaphore::new(config.max_concurrent_requests as usize)),
|
maximum_requests: Arc::new(Semaphore::new(config.max_concurrent_requests as usize)),
|
||||||
|
startup_netburst: config.startup_netburst,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,29 +125,29 @@ impl Service {
|
||||||
let mut receiver = self.receiver.lock().await;
|
let mut receiver = self.receiver.lock().await;
|
||||||
|
|
||||||
let mut futures = FuturesUnordered::new();
|
let mut futures = FuturesUnordered::new();
|
||||||
|
|
||||||
let mut current_transaction_status = HashMap::<OutgoingKind, TransactionStatus>::new();
|
let mut current_transaction_status = HashMap::<OutgoingKind, TransactionStatus>::new();
|
||||||
|
|
||||||
// Retry requests we could not finish yet
|
// Retry requests we could not finish yet
|
||||||
let mut initial_transactions = HashMap::<OutgoingKind, Vec<SendingEventType>>::new();
|
if self.startup_netburst {
|
||||||
|
let mut initial_transactions = HashMap::<OutgoingKind, Vec<SendingEventType>>::new();
|
||||||
|
for (key, outgoing_kind, event) in self.db.active_requests().filter_map(Result::ok) {
|
||||||
|
let entry = initial_transactions
|
||||||
|
.entry(outgoing_kind.clone())
|
||||||
|
.or_default();
|
||||||
|
|
||||||
for (key, outgoing_kind, event) in self.db.active_requests().filter_map(Result::ok) {
|
if entry.len() > 30 {
|
||||||
let entry = initial_transactions
|
warn!("Dropping some current events: {:?} {:?} {:?}", key, outgoing_kind, event);
|
||||||
.entry(outgoing_kind.clone())
|
self.db.delete_active_request(key)?;
|
||||||
.or_default();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if entry.len() > 30 {
|
entry.push(event);
|
||||||
warn!("Dropping some current events: {:?} {:?} {:?}", key, outgoing_kind, event);
|
|
||||||
self.db.delete_active_request(key)?;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
entry.push(event);
|
for (outgoing_kind, events) in initial_transactions {
|
||||||
}
|
current_transaction_status.insert(outgoing_kind.clone(), TransactionStatus::Running);
|
||||||
|
futures.push(Self::handle_events(outgoing_kind.clone(), events));
|
||||||
for (outgoing_kind, events) in initial_transactions {
|
}
|
||||||
current_transaction_status.insert(outgoing_kind.clone(), TransactionStatus::Running);
|
|
||||||
futures.push(Self::handle_events(outgoing_kind.clone(), events));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue