Skip to main content

Job

Struct Job 

Source
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: String

The subject, exactly as the queue keys on it — a repository path, an account.

§state: JobState§queue_position: u32

How 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::Order

What was asked for.

§report: K::Report

What the kind produced. Also reachable field-by-field through Deref.

§enqueued_at_unix_ms: i64§started_at_unix_ms: i64

0 until the job leaves JobState::Queued.

§finished_at_unix_ms: i64

0 until the job leaves JobState::Running.

Trait Implementations§

Source§

impl<K: JobKind> Clone for Job<K>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<K: JobKind> Debug for Job<K>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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.

Source§

type Target = <K as JobKind>::Report

The resulting type after dereferencing.
Source§

fn deref(&self) -> &K::Report

Dereferences the value.

Auto Trait Implementations§

§

impl<K> Freeze for Job<K>
where <K as JobKind>::Order: Freeze, <K as JobKind>::Report: Freeze,

§

impl<K> RefUnwindSafe for Job<K>

§

impl<K> Send for Job<K>
where <K as JobKind>::Order: Send, <K as JobKind>::Report: Send,

§

impl<K> Sync for Job<K>
where <K as JobKind>::Order: Sync, <K as JobKind>::Report: Sync,

§

impl<K> Unpin for Job<K>
where <K as JobKind>::Order: Unpin, <K as JobKind>::Report: Unpin,

§

impl<K> UnsafeUnpin for Job<K>

§

impl<K> UnwindSafe for Job<K>
where <K as JobKind>::Order: UnwindSafe, <K as JobKind>::Report: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Allocation for T
where T: RefUnwindSafe + Send + Sync,

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<L> LayerExt<L> for L

Source§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in Layered.
Source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more