pub struct JobQueue<K: JobKind> { /* private fields */ }Expand description
The queue: one worker, one job at a time, FIFO, deduplicated by subject.
Implementations§
Source§impl<K: JobKind> JobQueue<K>
impl<K: JobKind> JobQueue<K>
Sourcepub fn next_job_id(&self) -> String
pub fn next_job_id(&self) -> String
The job id the next enqueue would use, without enqueuing.
For a kind that has to name the job before it exists. A purge takes the
account’s lockout before enqueuing — that is what makes the lockout a
fact by the time Accounts.Purge returns — and the lockout’s holder has
to be the job id, or the release could not tell this job’s lockout from
anybody else’s.
Minted from the same counter JobQueue::enqueue uses, so an id handed
out here and never used simply leaves a gap. A gap in a job-id sequence
costs nothing; two jobs sharing an id would make the release ambiguous.
Sourcepub fn enqueue(&self, order: K::Order) -> Job<K>
pub fn enqueue(&self, order: K::Order) -> Job<K>
Ask for the order’s subject to be worked on, and return without working on it.
Returns the job now responsible for the subject: a new one, or the one already queued or running. Never enqueues a second job for a subject that has one live.
Sourcepub fn enqueue_as(&self, order: K::Order, job_id: String) -> Job<K>
pub fn enqueue_as(&self, order: K::Order, job_id: String) -> Job<K>
JobQueue::enqueue under an id taken from JobQueue::next_job_id
earlier.
The caller must not assume this id is the one that ends up responsible:
if a job for the same subject is already live, that one is returned and
this order’s id is never used. Accounts.Purge handles exactly that by
reading the gate back out of the table rather than trusting the one it
wrote.
Sourcepub fn status(&self, key: &str) -> Option<Job<K>>
pub fn status(&self, key: &str) -> Option<Job<K>>
The job the queue is holding for key, if it still has one.
Sourcepub fn peak_in_flight(&self) -> usize
pub fn peak_in_flight(&self) -> usize
The highest number of jobs of this kind that have ever been running together.
Must be 1 after any amount of traffic — that is the invariant this module exists for, and this is how a test sees it rather than infers it. 0 before anything has run.
Sourcepub fn runs(&self) -> u64
pub fn runs(&self) -> u64
How many times the kind’s run has been called — i.e. how much work
actually happened. The applied output the dedup gate asserts on.
Sourcepub fn stop(&self)
pub fn stop(&self)
Run nothing more after the job in flight, and refuse new jobs by name. For tests and the box’s stop; the lane’s worker ends when the last handle of the queue goes.
Sourcepub fn jera_stats(&self) -> Option<ChainStats>
pub fn jera_stats(&self) -> Option<ChainStats>
The queue’s jera lane, counted: its done and failed jobs (A32-14). None before the
first job, when no lane has started.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for JobQueue<K>
impl<K> RefUnwindSafe for JobQueue<K>where
Arc<Inner<K>>: RefUnwindSafe,
impl<K> Send for JobQueue<K>
impl<K> Sync for JobQueue<K>
impl<K> Unpin for JobQueue<K>
impl<K> UnsafeUnpin for JobQueue<K>where
Arc<Inner<K>>: UnsafeUnpin,
impl<K> UnwindSafe for JobQueue<K>where
Arc<Inner<K>>: UnwindSafe,
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,
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