Skip to content

Commit

Permalink
feat: auto remove invalid receivers from task
Browse files Browse the repository at this point in the history
  • Loading branch information
Threated committed Aug 30, 2024
1 parent fee8976 commit 42d2c46
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,17 @@ async fn handle_create_beam_task(
tokio::spawn(log_query(log_file, query.clone(), headers, result_log_sender_map));
}
let LensQuery { id, sites, query } = query;
let task = create_beam_task(id, sites, query);
let mut task = create_beam_task(id, sites, query);
match BEAM_CLIENT.post_task(&task).await {
Ok(()) => return Ok(StatusCode::CREATED),
Err(beam_lib::BeamError::InvalidReceivers(invalid)) => {
task.to.retain(|t| !invalid.contains(&t.proxy_id()));
},
Err(e) => {
warn!("Unable to query Beam.Proxy: {}", e);
return Err((StatusCode::BAD_GATEWAY, "Unable to query Beam.Proxy"))
}
};
BEAM_CLIENT.post_task(&task).await.map_err(|e| {
warn!("Unable to query Beam.Proxy: {}", e);
(StatusCode::BAD_GATEWAY, "Unable to query Beam.Proxy")
Expand Down

0 comments on commit 42d2c46

Please sign in to comment.