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
impl QueuedDemand
pub fn new(per_repository: BTreeMap<OwnerRepo, Vec<RunsOn>>) -> Self
Sourcepub fn of(repository: OwnerRepo, jobs: impl IntoIterator<Item = RunsOn>) -> Self
pub fn of(repository: OwnerRepo, jobs: impl IntoIterator<Item = RunsOn>) -> Self
One repository’s queued jobs, for the repository-target case and for tests.
Sourcepub fn with_truncated(self, repository: OwnerRepo) -> Self
pub fn with_truncated(self, repository: OwnerRepo) -> Self
Record that repository’s count is a floor rather than a total.
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.
Sourcepub fn total(&self) -> u32
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.
pub fn per_repository(&self) -> &BTreeMap<OwnerRepo, Vec<RunsOn>>
Sourcepub fn for_repository(&self, repository: &OwnerRepo) -> Option<u32>
pub fn for_repository(&self, repository: &OwnerRepo) -> Option<u32>
One repository’s unfiltered count, or None when it did not answer.
Sourcepub fn jobs_for(&self, repository: &OwnerRepo) -> &[RunsOn]
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.
Sourcepub fn jobs(&self) -> impl Iterator<Item = &RunsOn>
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.
pub fn truncated(&self) -> &BTreeSet<OwnerRepo>
pub fn is_truncated(&self, repository: &OwnerRepo) -> bool
Sourcepub fn is_complete(&self) -> bool
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
impl Clone for QueuedDemand
Source§fn clone(&self) -> QueuedDemand
fn clone(&self) -> QueuedDemand
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for QueuedDemand
impl Debug for QueuedDemand
Source§impl Default for QueuedDemand
impl Default for QueuedDemand
Source§fn default() -> QueuedDemand
fn default() -> QueuedDemand
impl Eq for QueuedDemand
Source§impl PartialEq for QueuedDemand
impl PartialEq for QueuedDemand
impl StructuralPartialEq for QueuedDemand
Auto Trait Implementations§
impl Freeze for QueuedDemand
impl RefUnwindSafe for QueuedDemand
impl Send for QueuedDemand
impl Sync for QueuedDemand
impl Unpin for QueuedDemand
impl UnsafeUnpin for QueuedDemand
impl UnwindSafe for QueuedDemand
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.