Skip to main content

TargetCost

Struct TargetCost 

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

What one target costs, per refresh, in requests against the shared ceiling.

§Why an organization is not a constant

04-subsystem-contracts.md tabulates a flat “per target, per hour” cost — ~240 at the 60-second default, ~480 at the 30-second floor — and that table is right for a repository target and wrong for an organization one. Two of the three request classes are per-repository resources:

ClassRepository targetOrganization target with n installed repositories
runner inventory11 (there is an org runners endpoint)
in-progress workflow count1n
demand: queued runs plus jobs22n
per refresh41 + 3n

At n = 1 the two agree exactly, at 4 requests per refresh and 240 per hour at the default interval, which is what makes this a refinement of the documented table rather than a contradiction of it. At n = 10 an organization costs 31 requests per refresh — nearly eight times a repository — and projecting it as one flat target understates the real spend by exactly that factor. f2’s org add refusal therefore arrives much earlier than a repository’s would, which is a thing it has to be able to explain.

§What this model does not claim

It is a projection of steady-state polling, in whole requests per refresh. It does not model a target whose runner inventory spans pages (a second page is a second request), an interactive auth status, a JIT registration, or a runner deletion. That is what BUDGET_SHARE_DIVISOR is for: the projection is compared against half the ceiling, and the other half absorbs everything this model deliberately does not attempt to count.

It also prices each repository’s activity count at its best case of one request. A count that has to take the no-total_count fallback costs up to MAX_ACTIVITY_FALLBACK_PAGES — see ACTIVITY_REQUESTS_PER_REPOSITORY_PER_REFRESH, which f1 and f2 read directly.

Implementations§

Source§

impl TargetCost

Source

pub const fn repository() -> Self

A repository target: one repository, by construction.

Source

pub const fn organization(installed_repositories: u32) -> Self

An organization target reaching installed_repositories repositories.

Source

pub fn with_demand_requests_per_repository(self, requests: u32) -> Self

Replace the demand cost with the one c4 measured.

c4’s specification says to “report the per-poll request count to c3’s budget model rather than estimating it there”, and this is where it reports it. Without a seam, honouring that sentence would mean editing DEMAND_REQUESTS_PER_REPOSITORY_PER_REFRESH — in this file, which c4 does not own — so the sentence would have been unfollowable and the estimate would have quietly stayed the truth.

The default is DEMAND_REQUESTS_PER_REPOSITORY_PER_REFRESH, which is what 04-subsystem-contracts.md tabulates. This overrides that number and nothing else: the inventory and activity costs are this task’s own and are measured against the requests it really issues.

Source

pub fn from_activity_scope(scope: &ActivityScope) -> Self

The cost of the scope an activity refresh will actually walk.

Preferred over TargetCost::organization wherever the repository set is already in hand, because it takes the count from the same list the requests will be issued against rather than from a number somebody passed in.

Source

pub const fn scope(&self) -> TargetScope

Source

pub const fn installed_repositories(&self) -> u32

Source

pub const fn requests_per_refresh(&self) -> u32

Requests one refresh of this target costs.

Source

pub fn requests_per_hour(&self, interval: RefreshInterval) -> u32

Requests one hour of refreshing this target at interval costs.

Trait Implementations§

Source§

impl Clone for TargetCost

Source§

fn clone(&self) -> TargetCost

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 Copy for TargetCost

Source§

impl Debug for TargetCost

Source§

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

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

impl Eq for TargetCost

Source§

impl PartialEq for TargetCost

Source§

fn eq(&self, other: &TargetCost) -> 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 TargetCost

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