Implement replay-safe authorized public HTTP API

This commit is contained in:
ms2k 2026-07-17 21:23:18 +09:00
commit 4c93c25692

View file

@ -16,8 +16,8 @@ use time::OffsetDateTime;
use crate::{
ActivationMutationOutcome, ActivationOutcome, AttemptAuthority, AttemptError,
AttemptFaultInjector, AttemptFaultPoint, AttemptState, CheckpointProjection, ClaimOutcome,
ClaimRejection, ExecutionEnvelopeRecord, LeaseProjection, RecoveryOutcome,
RenewalMutationOutcome, RenewalOutcome,
ClaimRejection, ExecutionEnvelopeRecord, LeaseProjection, ProgressRecord, ProgressSnapshot,
RecoveryOutcome, RenewalMutationOutcome, RenewalOutcome,
};
struct NoFaults;
@ -87,6 +87,27 @@ impl AttemptService {
})
}
pub async fn progress_snapshot(
&self,
job_id: &OpaqueId,
) -> Result<Option<ProgressSnapshot>, AttemptError> {
let Some(hint) = self.coordination.get_progress(job_id.as_str()).await? else {
return Ok(None);
};
Ok(Some(ProgressSnapshot {
attempt_id: OpaqueId::parse(hint.attempt_id)
.map_err(|error| AttemptError::Invalid(error.to_string()))?,
fence: hint.fence,
progress: ProgressRecord {
completed_bytes: hint.bytes,
total_bytes: hint.total_bytes,
completed_members: hint.completed_members,
total_members: hint.total_members,
},
observed_at: OffsetDateTime::now_utc(),
}))
}
pub async fn claim(
&self,
job_id: &OpaqueId,