mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-26 06:11:26 +00:00
remove else below continue
This commit is contained in:
parent
10758ab8ea
commit
373e61969d
1 changed files with 58 additions and 59 deletions
|
@ -116,9 +116,7 @@ impl InstanceWorker {
|
|||
/// loop fetch new activities from db and send them to the inboxes of the given instances
|
||||
/// this worker only returns if (a) there is an internal error or (b) the cancellation token is
|
||||
/// cancelled (graceful exit)
|
||||
async fn loop_until_stopped(
|
||||
&mut self,
|
||||
) -> Result<()> {
|
||||
async fn loop_until_stopped(&mut self) -> Result<()> {
|
||||
self.initial_fail_sleep().await?;
|
||||
let (mut last_sent_id, mut newest_id) = self.get_latest_ids().await?;
|
||||
|
||||
|
@ -139,13 +137,15 @@ impl InstanceWorker {
|
|||
// handle_send_results does not guarantee that we are now in a condition where we want to
|
||||
// send a new one, so repeat this check until the if no longer applies
|
||||
continue;
|
||||
} else {
|
||||
}
|
||||
|
||||
// send a new activity if there is one
|
||||
self.inbox_collector.update_communities().await?;
|
||||
let next_id_to_send = ActivityId(last_sent_id.0 + 1);
|
||||
{
|
||||
// sanity check: calculate next id to send based on the last id and the in flight requests
|
||||
let last_successful_id = self.state.last_successful_id.map(|e| e.0).context(
|
||||
let last_successful_id =
|
||||
self.state.last_successful_id.map(|e| e.0).context(
|
||||
"impossible: id is initialized in get_latest_ids and never returned to None",
|
||||
)?;
|
||||
let expected_next_id =
|
||||
|
@ -185,10 +185,7 @@ impl InstanceWorker {
|
|||
}
|
||||
self.in_flight += 1;
|
||||
last_sent_id = next_id_to_send;
|
||||
self
|
||||
.spawn_send_if_needed(next_id_to_send)
|
||||
.await?;
|
||||
}
|
||||
self.spawn_send_if_needed(next_id_to_send).await?;
|
||||
}
|
||||
tracing::debug!("cancelled worker loop after send");
|
||||
|
||||
|
@ -327,16 +324,15 @@ impl InstanceWorker {
|
|||
/// we collect the relevant inboxes in the main instance worker task, and only spawn the send task
|
||||
/// if we have inboxes to send to this limits CPU usage and reduces overhead for the (many)
|
||||
/// cases where we don't have any inboxes
|
||||
async fn spawn_send_if_needed(
|
||||
&mut self,
|
||||
activity_id: ActivityId,
|
||||
) -> Result<()> {
|
||||
async fn spawn_send_if_needed(&mut self, activity_id: ActivityId) -> Result<()> {
|
||||
let Some(ele) = get_activity_cached(&mut self.pool(), activity_id)
|
||||
.await
|
||||
.context("failed reading activity from db")?
|
||||
else {
|
||||
tracing::debug!("{}: {:?} does not exist", self.instance.domain, activity_id);
|
||||
self.report_send_result.send(SendActivityResult::Success(SendSuccessInfo {
|
||||
self
|
||||
.report_send_result
|
||||
.send(SendActivityResult::Success(SendSuccessInfo {
|
||||
activity_id,
|
||||
published: None,
|
||||
was_skipped: true,
|
||||
|
@ -353,13 +349,16 @@ impl InstanceWorker {
|
|||
// this is the case when the activity is not relevant to this receiving instance (e.g. no user
|
||||
// subscribed to the relevant community)
|
||||
tracing::debug!("{}: {:?} no inboxes", self.instance.domain, activity.id);
|
||||
self.report_send_result.send(SendActivityResult::Success(SendSuccessInfo {
|
||||
self
|
||||
.report_send_result
|
||||
.send(SendActivityResult::Success(SendSuccessInfo {
|
||||
activity_id,
|
||||
// it would be valid here to either return None or Some(activity.published). The published
|
||||
// time is only used for stats pages that track federation delay. None can be a bit
|
||||
// misleading because if you look at / chart the published time for federation from a large
|
||||
// to a small instance that's only subscribed to a few small communities, then it will show
|
||||
// the last published time as a days ago even though federation is up to date.
|
||||
// misleading because if you look at / chart the published time for federation from a
|
||||
// large to a small instance that's only subscribed to a few small communities,
|
||||
// then it will show the last published time as a days ago even though
|
||||
// federation is up to date.
|
||||
published: Some(activity.published),
|
||||
was_skipped: true,
|
||||
}))?;
|
||||
|
|
Loading…
Reference in a new issue