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
impl Constraints
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
skip_serializing_if helper — empty constraints are omitted
from the wire format entirely.
Sourcepub fn bad_skip_date(&self) -> Option<String>
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.
Sourcepub fn parse_window(s: &str) -> Result<(NaiveTime, NaiveTime), String>
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”).
Sourcepub fn allows(&self, now: DateTime<Utc>, tz: ScheduleTz) -> bool
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
impl Clone for Constraints
Source§fn clone(&self) -> Constraints
fn clone(&self) -> Constraints
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 Constraints
impl Debug for Constraints
Source§impl Default for Constraints
impl Default for Constraints
Source§fn default() -> Constraints
fn default() -> Constraints
Source§impl<'de> Deserialize<'de> for Constraints
impl<'de> Deserialize<'de> for Constraints
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for Constraints
impl JsonSchema for Constraints
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreSource§impl PartialEq for Constraints
impl PartialEq for Constraints
Source§fn eq(&self, other: &Constraints) -> bool
fn eq(&self, other: &Constraints) -> bool
self and other values to be equal, and is used by ==.