pub struct PurgeQueue(/* private fields */);Expand description
The queue: one worker, one purge at a time, FIFO, deduplicated by account.
A named type over JobQueue<Purge> rather than an alias, so
Accounts.Purge’s door keeps taking a PurgeOrder and taking its job id
out first, which is the shape the gate demands.
Implementations§
Source§impl PurgeQueue
impl PurgeQueue
Sourcepub fn new(run: PurgeRunner, release: GateRelease) -> Self
pub fn new(run: PurgeRunner, release: GateRelease) -> Self
A queue over run, releasing gates through release. No thread is
started until something is enqueued.
Sourcepub fn next_job_id(&self) -> String
pub fn next_job_id(&self) -> String
The job id the NEXT enqueue would use, without enqueuing.
The gate has to be taken before the job exists — that is what makes the
lockout a fact by the time Accounts.Purge returns — and the gate’s
holder has to be the job id, or the release could not tell this job’s
lockout from anybody else’s. So the id is minted here, handed to the
gate, and handed back in on PurgeQueue::enqueue inside the order.
Minting from the same counter as enqueue, 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: PurgeOrder) -> PurgeJob
pub fn enqueue(&self, order: PurgeOrder) -> PurgeJob
Ask for an account to be emptied.
Returns the job now responsible for the account: a new one, or the one
that was already queued or running — in which case this order’s
job_id is not used, and the caller must not assume its gate is the
one that will be released. Accounts.Purge handles that by reading the
gate back out of the table rather than trusting the one it wrote.
Sourcepub fn status(&self, account: &str) -> Option<PurgeJob>
pub fn status(&self, account: &str) -> Option<PurgeJob>
The job the queue is holding for account, if it still has one.
Sourcepub fn peak_in_flight(&self) -> usize
pub fn peak_in_flight(&self) -> usize
The highest number of purges that have ever run together. Must be 1.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for PurgeQueue
impl !UnwindSafe for PurgeQueue
impl Freeze for PurgeQueue
impl Send for PurgeQueue
impl Sync for PurgeQueue
impl Unpin for PurgeQueue
impl UnsafeUnpin for PurgeQueue
Blanket Implementations§
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