mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Avoid delay in bumping "loading_more" relay count
This commit is contained in:
parent
f54645b6b7
commit
5710a667aa
@ -88,6 +88,7 @@ pub struct Minion {
|
|||||||
exiting: Option<MinionExitReason>,
|
exiting: Option<MinionExitReason>,
|
||||||
auth_state: AuthState,
|
auth_state: AuthState,
|
||||||
failed_subs: HashSet<String>,
|
failed_subs: HashSet<String>,
|
||||||
|
initial_handling: bool,
|
||||||
loading_more: usize,
|
loading_more: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,6 +130,7 @@ impl Minion {
|
|||||||
exiting: None,
|
exiting: None,
|
||||||
auth_state: AuthState::None,
|
auth_state: AuthState::None,
|
||||||
failed_subs: HashSet::new(),
|
failed_subs: HashSet::new(),
|
||||||
|
initial_handling: true,
|
||||||
loading_more: 0,
|
loading_more: 0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -151,6 +153,21 @@ impl Minion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optimization: before connecting to the relay, handle any 'loading_more' bumps
|
||||||
|
// that would happen after connecting to the relay.
|
||||||
|
for message in &messages {
|
||||||
|
let loading_more =
|
||||||
|
matches!(message.detail, ToMinionPayloadDetail::TempSubscribeGeneralFeedChunk(_))
|
||||||
|
||
|
||||||
|
matches!(message.detail, ToMinionPayloadDetail::TempSubscribePersonFeedChunk { .. })
|
||||||
|
||
|
||||||
|
matches!(message.detail, ToMinionPayloadDetail::TempSubscribeInboxFeedChunk(_));
|
||||||
|
if loading_more {
|
||||||
|
self.loading_more += 1;
|
||||||
|
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let fetcher_timeout = if short_timeout {
|
let fetcher_timeout = if short_timeout {
|
||||||
std::time::Duration::new(5, 0)
|
std::time::Duration::new(5, 0)
|
||||||
} else {
|
} else {
|
||||||
@ -332,6 +349,8 @@ impl Minion {
|
|||||||
self.handle_overlord_message(message).await?;
|
self.handle_overlord_message(message).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.initial_handling = false;
|
||||||
|
|
||||||
// Ping timer
|
// Ping timer
|
||||||
let mut ping_timer = tokio::time::interval(std::time::Duration::new(
|
let mut ping_timer = tokio::time::interval(std::time::Duration::new(
|
||||||
GLOBALS.storage.read_setting_websocket_ping_frequency_sec(),
|
GLOBALS.storage.read_setting_websocket_ping_frequency_sec(),
|
||||||
@ -860,8 +879,10 @@ impl Minion {
|
|||||||
))?;
|
))?;
|
||||||
} else {
|
} else {
|
||||||
let sub_name = format!("temp_person_feed_chunk_{}", job_id);
|
let sub_name = format!("temp_person_feed_chunk_{}", job_id);
|
||||||
self.loading_more += 1;
|
if ! self.initial_handling {
|
||||||
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
self.loading_more += 1;
|
||||||
|
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
||||||
|
}
|
||||||
self.subscribe(filters, &sub_name, job_id).await?;
|
self.subscribe(filters, &sub_name, job_id).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -893,8 +914,10 @@ impl Minion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let sub_name = format!("temp_inbox_feed_chunk_{}", job_id);
|
let sub_name = format!("temp_inbox_feed_chunk_{}", job_id);
|
||||||
self.loading_more += 1;
|
if ! self.initial_handling {
|
||||||
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
self.loading_more += 1;
|
||||||
|
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
||||||
|
}
|
||||||
self.subscribe(filters, &sub_name, job_id).await?;
|
self.subscribe(filters, &sub_name, job_id).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -1093,8 +1116,10 @@ impl Minion {
|
|||||||
// the new chunk subscription doesn't clobber this subscription which might
|
// the new chunk subscription doesn't clobber this subscription which might
|
||||||
// not have run to completion yet.
|
// not have run to completion yet.
|
||||||
let sub_name = format!("temp_general_feed_chunk_{}", job_id);
|
let sub_name = format!("temp_general_feed_chunk_{}", job_id);
|
||||||
self.loading_more += 1;
|
if ! self.initial_handling {
|
||||||
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
self.loading_more += 1;
|
||||||
|
let _ = GLOBALS.loading_more.fetch_add(1, Ordering::SeqCst);
|
||||||
|
}
|
||||||
self.subscribe(filters, &sub_name, job_id).await?;
|
self.subscribe(filters, &sub_name, job_id).await?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user