Fetch the result of a job more than once if needed

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
This commit is contained in:
Lee Smet
2025-09-08 11:54:15 +02:00
parent 8cea17f4ec
commit 78a776877a

View File

@@ -386,12 +386,9 @@ async fn deliver_one(
// Stop on terminal states // Stop on terminal states
if matches!(s, TransportStatus::Delivered | TransportStatus::Read) { if matches!(s, TransportStatus::Delivered | TransportStatus::Read) {
// Only request a single job status/result per message
if !requested_job_check {
if let Some(job_id) = job_id_opt { if let Some(job_id) = job_id_opt {
// First consult Redis for the latest job state in case we already have a terminal update // First consult Redis for the latest job state in case we already have a terminal update
match service_poll.load_job(context_id, caller_id, job_id).await match service_poll.load_job(context_id, caller_id, job_id).await {
{
Ok(job) => { Ok(job) => {
match job.status() { match job.status() {
JobStatus::Finished | JobStatus::Error => { JobStatus::Finished | JobStatus::Error => {
@@ -499,7 +496,9 @@ async fn deliver_one(
} else if let Some(s) = } else if let Some(s) =
res.and_then(|v| v.as_str()) res.and_then(|v| v.as_str())
{ {
let mut patch = std::collections::HashMap::new(); let mut patch =
std::collections::HashMap::new(
);
patch.insert( patch.insert(
"success".to_string(), "success".to_string(),
s.to_string(), s.to_string(),
@@ -578,16 +577,12 @@ async fn deliver_one(
secret_for_poller.clone(), secret_for_poller.clone(),
) )
.await; .await;
match sup match sup.job_status_wait(job_id.to_string()).await
.job_status_wait(job_id.to_string())
.await
{ {
Ok((_out_id, reply_status)) => { Ok((_out_id, reply_status)) => {
// Interpret status reply synchronously // Interpret status reply synchronously
let result_opt = let result_opt = reply_status.get("result");
reply_status.get("result"); let error_opt = reply_status.get("error");
let error_opt =
reply_status.get("error");
if let Some(err_obj) = error_opt { if let Some(err_obj) = error_opt {
let _ = service_poll let _ = service_poll
.update_job_status_unchecked( .update_job_status_unchecked(
@@ -614,10 +609,7 @@ async fn deliver_one(
if let Some(remote_status) = if let Some(remote_status) =
status_candidate status_candidate
{ {
if let Some(( if let Some((mapped, terminal)) =
mapped,
terminal,
)) =
map_supervisor_job_status( map_supervisor_job_status(
remote_status, remote_status,
) )
@@ -692,7 +684,10 @@ async fn deliver_one(
context_id, context_id,
caller_id, caller_id,
id, id,
vec![format!("job.status request error: {}", e)], vec![format!(
"job.status request error: {}",
e
)],
) )
.await; .await;
} }
@@ -743,7 +738,6 @@ async fn deliver_one(
// Ensure we only do this once // Ensure we only do this once
requested_job_check = true; requested_job_check = true;
} }
}
// break; // break;
} }
if matches!(s, TransportStatus::Failed) { if matches!(s, TransportStatus::Failed) {