pub struct Job<K: JobKind> {
pub job_id: String,
pub key: String,
pub state: JobState,
pub queue_position: u32,
pub progress: Option<(u64, u64)>,
pub error: Option<String>,
pub order: K::Order,
pub report: K::Report,
pub enqueued_at_unix_ms: i64,
pub started_at_unix_ms: i64,
pub finished_at_unix_ms: i64,
}Expand description
One job of kind K, queued or completed.
The fields above the line are the queue’s and are the same for every kind —
which is what lets GcStatus, PurgeStatus and a future MirrorStatus
render from one shape. report is the kind’s own, and Job dereferences
to it so a caller writes job.bytes_reclaimed for the gc’s field and
job.state for the queue’s, without having to know which half it is in.
Fields§
§job_id: String§key: StringThe subject, exactly as the queue keys on it — a repository path, an account.
state: JobState§queue_position: u32How many jobs are ahead of this one; 0 unless JobState::Queued.
Computed from the waiting list at read time and never stored, because a stored position is wrong the moment the job in front of it starts, and a queue that reported stale positions would be worse than one that reported none.
progress: Option<(u64, u64)>How far along, as (done, total) — whatever the kind counts in.
None until the job reports one, and for kinds that never do: a gc and
a purge each finish in one indivisible act as far as a caller is
concerned, and a fabricated 0/1 would be a progress bar that lies. A
mirror cannot do without it — a fetch of a large repository is minutes
of network with somebody watching, and a job that sat at Running and
then jumped to Done tells that watcher nothing.
error: Option<String>Only set when JobState::Failed.
order: K::OrderWhat was asked for.
report: K::ReportWhat the kind produced. Also reachable field-by-field through Deref.
enqueued_at_unix_ms: i64§started_at_unix_ms: i640 until the job leaves JobState::Queued.
finished_at_unix_ms: i640 until the job leaves JobState::Running.
Trait Implementations§
Source§impl<K: JobKind> Deref for Job<K>
A job reads as one flat record, the queue’s fields and the kind’s
together.
impl<K: JobKind> Deref for Job<K>
A job reads as one flat record, the queue’s fields and the kind’s together.
Not inheritance-by-Deref: a Job is an envelope the queue wraps around
exactly one K::Report, the way a newtype wraps its payload, and the target
is a plain data struct with no methods of its own — so there is nothing here
for a method call to resolve to by surprise. job.report is always
available for anyone who would rather be explicit.
Auto Trait Implementations§
impl<K> Freeze for Job<K>
impl<K> RefUnwindSafe for Job<K>
impl<K> Send for Job<K>
impl<K> Sync for Job<K>
impl<K> Unpin for Job<K>
impl<K> UnsafeUnpin for Job<K>
impl<K> UnwindSafe for Job<K>
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Formattable for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request