Skip to main content

Constraints

Struct Constraints 

Source
pub struct Constraints {
    pub window: Option<String>,
    pub max_concurrent: Option<u32>,
    pub skip_dates: Vec<String>,
    pub require: Option<Require>,
}
Expand description

Active decides over what date range a schedule is live, Constraints decides when, within an active period, a fire is allowed: window (a maintenance time-of-day window), max_concurrent (a fleet-wide running-instance cap), skip_dates (holiday exclusion) and require (host-environment gates, agent-only — see Require).

Fields§

§window: Option<String>

"HH:MM-HH:MM" wall-clock window (evaluated in the schedule’s tz). Fires outside it are skipped — mainly for reconcile cadences (“patrol every 6h, but only fire overnight”) and daytime change-freezes. start > end crosses midnight ("22:00-05:00" = 22:00 through 05:00 next morning). Parsed lazily; Schedule::validate rejects garbage at create time.

§max_concurrent: Option<u32>

Fleet-wide cap on how many instances of this schedule’s job may run at the same time (#418 “同時実行ハード上限”). The backend scheduler counts the job’s still-in-flight runs (execution_results.finished_at IS NULL) each tick and only dispatches to as many remaining pcs as there are free slots — a rolling window that refills as runs complete. Useful for disk/CPU/network-heavy jobs you don’t want hammering the whole fleet at once.

Backend-only (it needs a central counter): combining it with runs_on: agent is rejected by Schedule::validate (#418 decision E — “中央上限には中央が要る”). Most meaningful for per_pc reconcile cadences, where the poll re-ticks and refills slots. None (default) = no cap.

§skip_dates: Vec<String>

Calendar dates the schedule must not fire on — holidays, blackout days, one-off freeze dates (#418 “祝日除外”). Each is YYYY-MM-DD, evaluated as a wall-clock date in the schedule’s tz. Applies to every when shape (a reconcile cadence skips the whole day; a calendar fire landing on the date is suppressed) and is honored by both the live scheduler and preview, since both gate on Constraints::allows. Empty (default) = no skips. Operator-supplied: there is no built-in holiday calendar — list the dates you care about. Parsed lazily; Schedule::validate rejects a malformed date at create time.

§require: Option<Require>

Host-environment gate (#418): fire only when the target host is in the required state (on AC power, idle). Agent-sensed at fire time, runs_on: agent only. See Require. None (default) = no environment requirement.

Implementations§

Source§

impl Constraints

Source

pub fn is_empty(&self) -> bool

skip_serializing_if helper — empty constraints are omitted from the wire format entirely.

Source

pub fn bad_skip_date(&self) -> Option<String>

The first unparseable skip_dates entry, if any — the scheduler logs it at register time so a fail-closed (never-firing) schedule from a hand-edited KV blob is diagnosable, mirroring Schedule::bad_window.

Source

pub fn parse_window(s: &str) -> Result<(NaiveTime, NaiveTime), String>

Parse "HH:MM-HH:MM" into (start, end). Equal bounds are an error (a zero-width or all-day window is ambiguous — write no window for “always”).

Source

pub fn allows(&self, now: DateTime<Utc>, tz: ScheduleTz) -> bool

Is a fire allowed at now (evaluated in tz)? No window = always allowed. Half-open [start, end); start > end crosses midnight.

Fail-closed on an unparseable window (returns false, gemini #452 review): a window is a restrictive constraint (change-freeze / overnight-only), so a corrupt one must NOT silently allow fires during the restricted hours. Bad windows are rejected at create time by Schedule::validate; this only bites a hand-edited KV blob, where blocking is the safe direction. The scheduler warns at register time (Schedule::bad_window) so a stuck schedule is diagnosable. The tick path never panics regardless.

Trait Implementations§

Source§

impl Clone for Constraints

Source§

fn clone(&self) -> Constraints

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 Constraints

Source§

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

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

impl Default for Constraints

Source§

fn default() -> Constraints

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

impl<'de> Deserialize<'de> for Constraints

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 JsonSchema for Constraints

Source§

fn schema_name() -> Cow<'static, str>

The name of the generated JSON Schema. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn inline_schema() -> bool

Whether JSON Schemas generated for this type should be included directly in parent schemas, rather than being re-used where possible using the $ref keyword. Read more
Source§

impl PartialEq for Constraints

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Constraints

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 Constraints

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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