Skip to main content

PolicyMode

Enum PolicyMode 

Source
pub enum PolicyMode {
    MonitorOnly,
    Autoscale(AutoscaleConfig),
}
Expand description

D19, as an enforced invariant rather than a convention.

04-subsystem-contracts.md:

  • MonitorOnly requires routing_labels and max_capacity to be None.”
  • Autoscale requires both to be Some.”

The contract writes those as three flat, independently-Optional fields on ScalePolicy, which admits four combinations of which two are illegal. This enum admits exactly the two legal ones, so the illegal pair has no representation — b1 asks for that explicitly: “Prefer a representation where the illegal combination cannot be built at all over one that is merely validated on the way in.”

The flat shape is still reachable: PolicyMode::routing_labels, PolicyMode::min_capacity, and PolicyMode::max_capacity return exactly the Options the contract names, and PolicyMode::from_persisted rebuilds the mode from them. That is b2’s load path, and it is where a hand-edited database row is rejected.

Variants§

§

MonitorOnly

Contributes runners and workflow counts to the dashboard; owns no routing label; skipped entirely by reconciliation.

§

Autoscale(AutoscaleConfig)

Starts runners, up to max_capacity and the host ceiling.

Implementations§

Source§

impl PolicyMode

Source

pub const fn monitor_only() -> Self

Source

pub fn autoscale( routing_labels: RoutingLabels, min_capacity: u16, max_capacity: NonZeroU16, ) -> Result<Self, PolicyError>

Source

pub fn from_persisted( routing_labels: Option<RoutingLabels>, min_capacity: u16, max_capacity: Option<NonZeroU16>, ) -> Result<Self, PolicyError>

Rebuild the mode from the flat persisted shape.

This is the gate b2 puts every load through. All four combinations of routing_labels/max_capacity arrive here, and two of them are refused with a named error rather than being coerced into something plausible.

§Errors

Each illegal shape gets its own variant, so b2 can say which column of which row is wrong rather than “invalid policy”.

Source

pub const fn routing_labels(&self) -> Option<&RoutingLabels>

The contract’s routing_labels: Option<NonEmpty<Label>>, in Option form.

Source

pub const fn min_capacity(&self) -> u16

Source

pub const fn max_capacity(&self) -> Option<NonZeroU16>

Source

pub const fn autoscale_config(&self) -> Option<&AutoscaleConfig>

Source

pub const fn is_autoscale(&self) -> bool

Source

pub const fn is_monitor_only(&self) -> bool

Trait Implementations§

Source§

impl Clone for PolicyMode

Source§

fn clone(&self) -> PolicyMode

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 PolicyMode

Source§

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

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

impl<'de> Deserialize<'de> for PolicyMode

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for PolicyMode

Source§

impl PartialEq for PolicyMode

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for PolicyMode

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PolicyMode

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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<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> 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