lint and set force_write true when a request fails

This commit is contained in:
phiresky 2024-04-15 17:59:26 +02:00
parent 491daabaf2
commit 987174a6c1
2 changed files with 11 additions and 16 deletions

View file

@ -79,15 +79,7 @@ async fn start_stop_federation_workers(
let instance = instance.clone();
let config = config.clone();
let stats_sender = stats_sender.clone();
async move {
InstanceWorker::init_and_loop(
instance,
config,
stop,
stats_sender,
)
.await
}
async move { InstanceWorker::init_and_loop(instance, config, stop, stats_sender).await }
}),
);
} else if !should_federate {

View file

@ -231,7 +231,7 @@ impl InstanceWorker {
/// get newest activity id and set it as last_successful_id if it's the first time this instance is seen
async fn get_latest_id(&mut self) -> Result<ActivityId> {
let latest_id = get_latest_activity_id(&mut self.pool()).await?;
if let None = self.state.last_successful_id {
if self.state.last_successful_id.is_none() {
// this is the initial creation (instance first seen) of the federation queue for this instance
// skip all past activities:
self.state.last_successful_id = Some(latest_id);
@ -247,7 +247,7 @@ impl InstanceWorker {
successfuls: &mut BinaryHeap<SendSuccessInfo>,
in_flight: &mut i64,
) -> Result<(), anyhow::Error> {
let force_write = false;
let mut force_write = false;
let mut events = Vec::new();
// wait for at least one event but if there's multiple handle them all
receive_inbox_result.recv_many(&mut events, 1000).await;
@ -266,6 +266,7 @@ impl InstanceWorker {
// override fail count - if multiple activities are currently sending this value may get conflicting info but that's fine
self.state.fail_count = fail_count;
self.state.last_retry = Some(Utc::now());
force_write = true;
}
}
}
@ -378,11 +379,13 @@ impl InstanceWorker {
ele.0.ap_id,
e
);
report.send(SendActivityResult::Success(SendSuccessInfo {
activity_id,
published: None,
was_skipped: true,
})).ok();
report
.send(SendActivityResult::Success(SendSuccessInfo {
activity_id,
published: None,
was_skipped: true,
}))
.ok();
}
});
Ok(())