mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-30 00:01:25 +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
|
/// 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
|
/// this worker only returns if (a) there is an internal error or (b) the cancellation token is
|
||||||
/// cancelled (graceful exit)
|
/// cancelled (graceful exit)
|
||||||
async fn loop_until_stopped(
|
async fn loop_until_stopped(&mut self) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
) -> Result<()> {
|
|
||||||
self.initial_fail_sleep().await?;
|
self.initial_fail_sleep().await?;
|
||||||
let (mut last_sent_id, mut newest_id) = self.get_latest_ids().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
|
// 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
|
// send a new one, so repeat this check until the if no longer applies
|
||||||
continue;
|
continue;
|
||||||
} else {
|
}
|
||||||
|
|
||||||
// send a new activity if there is one
|
// send a new activity if there is one
|
||||||
self.inbox_collector.update_communities().await?;
|
self.inbox_collector.update_communities().await?;
|
||||||
let next_id_to_send = ActivityId(last_sent_id.0 + 1);
|
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
|
// 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",
|
"impossible: id is initialized in get_latest_ids and never returned to None",
|
||||||
)?;
|
)?;
|
||||||
let expected_next_id =
|
let expected_next_id =
|
||||||
|
@ -185,10 +185,7 @@ impl InstanceWorker {
|
||||||
}
|
}
|
||||||
self.in_flight += 1;
|
self.in_flight += 1;
|
||||||
last_sent_id = next_id_to_send;
|
last_sent_id = next_id_to_send;
|
||||||
self
|
self.spawn_send_if_needed(next_id_to_send).await?;
|
||||||
.spawn_send_if_needed(next_id_to_send)
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
tracing::debug!("cancelled worker loop after send");
|
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
|
/// 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)
|
/// 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
|
/// cases where we don't have any inboxes
|
||||||
async fn spawn_send_if_needed(
|
async fn spawn_send_if_needed(&mut self, activity_id: ActivityId) -> Result<()> {
|
||||||
&mut self,
|
|
||||||
activity_id: ActivityId,
|
|
||||||
) -> Result<()> {
|
|
||||||
let Some(ele) = get_activity_cached(&mut self.pool(), activity_id)
|
let Some(ele) = get_activity_cached(&mut self.pool(), activity_id)
|
||||||
.await
|
.await
|
||||||
.context("failed reading activity from db")?
|
.context("failed reading activity from db")?
|
||||||
else {
|
else {
|
||||||
tracing::debug!("{}: {:?} does not exist", self.instance.domain, activity_id);
|
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,
|
activity_id,
|
||||||
published: None,
|
published: None,
|
||||||
was_skipped: true,
|
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
|
// this is the case when the activity is not relevant to this receiving instance (e.g. no user
|
||||||
// subscribed to the relevant community)
|
// subscribed to the relevant community)
|
||||||
tracing::debug!("{}: {:?} no inboxes", self.instance.domain, activity.id);
|
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,
|
activity_id,
|
||||||
// it would be valid here to either return None or Some(activity.published). The published
|
// 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
|
// 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
|
// misleading because if you look at / chart the published time for federation from a
|
||||||
// to a small instance that's only subscribed to a few small communities, then it will show
|
// large to a small instance that's only subscribed to a few small communities,
|
||||||
// the last published time as a days ago even though federation is up to date.
|
// then it will show the last published time as a days ago even though
|
||||||
|
// federation is up to date.
|
||||||
published: Some(activity.published),
|
published: Some(activity.published),
|
||||||
was_skipped: true,
|
was_skipped: true,
|
||||||
}))?;
|
}))?;
|
||||||
|
|
Loading…
Reference in a new issue