Skip to main content

QueuedDemand

Struct QueuedDemand 

Source
pub struct QueuedDemand { /* private fields */ }
Expand description

Queued jobs, per repository, each carrying the runs-on it requires.

This is a count of jobs, not of runs, and it is not filtered by any policy’s routing labels — but it carries everything needed to filter it. Both facts are the module documentation’s subject and are repeated on the type because this is what a caller holds.

The unfiltered totals (QueuedDemand::total, QueuedDemand::for_repository) are the raw queue depth, which is what g2 renders for an operator: “what is waiting in this repository”, independent of which host could serve it. The number e1 clamps is not either of those. It comes from tallying QueuedDemand::jobs_for against one policy’s routing labels, and the difference between the two is exactly the jobs this host cannot serve.

§A count can be short in two different ways, and both have to say so

A repository can fail to answer at all (QueuedDemand::unavailable), and a repository can answer with a number that is only a floor (QueuedDemand::truncated) — more runs were active than MAX_QUEUED_RUNS_PER_REPOSITORY_PER_POLL and MAX_IN_PROGRESS_RUNS_PER_REPOSITORY_PER_POLL allow resolving, or one run’s job listing walked to MAX_JOB_PAGES_PER_RUN. QueuedDemand::is_complete is false for either.

The shape mirrors crate::rest::ActivityCount deliberately, down to the method names, because g2 renders the two side by side and a caller that has learned one should not have to learn the other. They stay separate types for the reason c3 keeps the busy-runner count and the in-progress count apart: a type that can hold either number is a type that will eventually add them.

Implementations§

Source§

impl QueuedDemand

Source

pub fn new(per_repository: BTreeMap<OwnerRepo, Vec<RunsOn>>) -> Self

Source

pub fn of(repository: OwnerRepo, jobs: impl IntoIterator<Item = RunsOn>) -> Self

One repository’s queued jobs, for the repository-target case and for tests.

Source

pub fn with_truncated(self, repository: OwnerRepo) -> Self

Record that repository’s count is a floor rather than a total.

Source

pub fn with_unavailable( self, repository: OwnerRepo, reason: impl Into<String>, ) -> Self

Record that repository could not be read at all, and why.

Deliberately not the same as a count of zero: nothing was learned about it, and a zero would render a possibly-busy repository as idle.

Source

pub fn total(&self) -> u32

Queued jobs across every repository that answered, unfiltered.

The raw queue depth, not the demand any one policy should serve. See the type documentation for the distinction, which is the whole reason QueuedDemand::jobs exists beside this.

Saturating rather than wrapping: a total wider than a u32 is not a number to wrap around zero, and u32::MAX runners is refused by the capacity ceilings long before it means anything.

Source

pub fn per_repository(&self) -> &BTreeMap<OwnerRepo, Vec<RunsOn>>

Source

pub fn for_repository(&self, repository: &OwnerRepo) -> Option<u32>

One repository’s unfiltered count, or None when it did not answer.

Source

pub fn jobs_for(&self, repository: &OwnerRepo) -> &[RunsOn]

One repository’s queued jobs, as the runs-on each requires.

This is the input b1’s predicate was written for and never had. An empty slice for a repository that answered means it really is idle; a repository that did not answer is in QueuedDemand::unavailable instead, and the two must not be conflated.

Source

pub fn jobs(&self) -> impl Iterator<Item = &RunsOn>

Every queued job across every repository that answered.

What an organization target tallies, for the reason a repository target tallies QueuedDemand::jobs_for: one policy watching an organization serves any repository in it, so its demand is the whole scope’s.

Source

pub fn unavailable(&self) -> &[UnavailableRepository]

Source

pub fn truncated(&self) -> &BTreeSet<OwnerRepo>

Source

pub fn is_truncated(&self, repository: &OwnerRepo) -> bool

Source

pub fn is_complete(&self) -> bool

Whether every repository in scope answered with an exact count.

false means the total is a floor. Scaling up from a floor is safe; concluding “idle” from one is not, which is the mistake this exists to make expressible.

Trait Implementations§

Source§

impl Clone for QueuedDemand

Source§

fn clone(&self) -> QueuedDemand

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 Debug for QueuedDemand

Source§

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

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

impl Default for QueuedDemand

Source§

fn default() -> QueuedDemand

Returns the “default value” for a type. Read more
Source§

impl Eq for QueuedDemand

Source§

impl PartialEq for QueuedDemand

Source§

fn eq(&self, other: &QueuedDemand) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for QueuedDemand

Auto Trait Implementations§

Blanket Implementations§

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<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<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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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