add conf item to toggle startup netburst (for developers).

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-03-27 14:47:21 -07:00 committed by June
parent 3cf67f3993
commit 125ff21c88
2 changed files with 24 additions and 16 deletions

View file

@ -226,6 +226,9 @@ pub struct Config {
#[serde(with = "serde_regex")]
pub forbidden_usernames: RegexSet,
#[serde(default = "default_startup_netburst")]
pub startup_netburst: bool,
#[serde(default)]
pub block_non_admin_invites: bool,
@ -518,6 +521,7 @@ impl fmt::Display for Config {
"Allow check for updates / announcements check",
&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();
@ -675,3 +679,5 @@ fn default_url_preview_max_spider_size() -> usize {
}
fn default_new_user_displayname_suffix() -> String { "🏳️‍⚧️".to_owned() }
fn default_startup_netburst() -> bool { true }

View file

@ -90,6 +90,7 @@ pub struct Service {
pub(super) maximum_requests: Arc<Semaphore>,
pub sender: mpsc::UnboundedSender<(OutgoingKind, SendingEventType, Vec<u8>)>,
receiver: Mutex<mpsc::UnboundedReceiver<(OutgoingKind, SendingEventType, Vec<u8>)>>,
startup_netburst: bool,
}
enum TransactionStatus {
@ -106,6 +107,7 @@ impl Service {
sender,
receiver: Mutex::new(receiver),
maximum_requests: Arc::new(Semaphore::new(config.max_concurrent_requests as usize)),
startup_netburst: config.startup_netburst,
})
}
@ -123,12 +125,11 @@ impl Service {
let mut receiver = self.receiver.lock().await;
let mut futures = FuturesUnordered::new();
let mut current_transaction_status = HashMap::<OutgoingKind, TransactionStatus>::new();
// Retry requests we could not finish yet
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())
@ -147,6 +148,7 @@ impl Service {
current_transaction_status.insert(outgoing_kind.clone(), TransactionStatus::Running);
futures.push(Self::handle_events(outgoing_kind.clone(), events));
}
}
loop {
select! {