infrastructure tier

infrastructure-cron

Timezone-aware cron scheduler composing over infrastructure-jobs: durable beat ledger, replica-safe exactly-once beats, bounded catch-up

Timezone-aware cron scheduler composing over infrastructure-jobs: durable beat ledger, replica-safe exactly-once beats, bounded catch-up

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/cron
Edition2021
Targetsinfrastructure_cron, beats
Public items7 across 0 modules
Tests13

What it is for

# infrastructure-cron

Timezone-aware cron scheduling that composes over `infrastructure-jobs` (Sprint 2.4 US-2.4.3, consensus #11). This crate owns cron syntax, timezone and DST handling, the durable beat ledger, catch-up policy, and replica-safe beat claiming; the jobs crate knows nothing about any of it.

A beat is one scheduled instant. Each beat is claimed exactly once across N replicas via a unique (schedule_id, beat_at) insert, then enqueued as an ordinary job — so cron inherits every jobs guarantee (fencing, backoff, DLQ).

The tz-aware beat calculation is harvested from rfpdb's proven due_beats_tz.

Capabilities

crate root

# infrastructure-cron

Item
fn to_six_field(expr : & str) -> String

CatchupPolicy

# infrastructure-cron

Item
pub enum CatchupPolicy
fn select_beats(all_due : & DateTime <Utc>, policy : CatchupPolicy, ceiling : usize,) -> Vec <DateTime <Utc>>

CronError

# infrastructure-cron

Item
pub enum CronError
fn due_beats_tz(cron_expr : & str, tz : chrono_tz::Tz, window_start : DateTime <Utc>, window_end : DateTime <Utc>,) -> Result <Vec <DateTime <Utc>>, CronError>

Schedule

# infrastructure-cron

Item
pub struct Schedule
fn uncovered_schedules(schedules : & Schedule, registered_handlers : & std::collections::HashSet <String>,) -> Vec <String>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub enum CronErrorErrors from cron parsing or scheduling.
pub enum CatchupPolicyWhat to do with beats missed while the scheduler was down (consensus #12)
pub struct ScheduleA registered schedule.
fn to_six_field(expr : & str) -> StringNormalise a 5-field cron (min hour dom mon dow) to the 6-field form the cron crate expects (sec min hour dom mon dow) by prepending 0 seconds.
fn due_beats_tz(cron_expr : & str, tz : chrono_tz::Tz, window_start : DateTime <Utc>, window_end : DateTime <Utc>,) -> Result <Vec <DateTime <Utc>>, CronError>All beats for cron_expr (interpreted in tz) within window_start, window_end, returned in UTC
fn select_beats(all_due : & DateTime <Utc>, policy : CatchupPolicy, ceiling : usize,) -> Vec <DateTime <Utc>>Apply the catch-up policy to the full set of due beats (consensus #12)
fn uncovered_schedules(schedules : & Schedule, registered_handlers : & std::collections::HashSet <String>,) -> Vec <String>Startup drift check (US-2.4.11): the schedule ids whose job type has no registered handler

Re-exports. Exported here, defined elsewhere.

ExportDefined in
{claim_beat,ensure_beat_ledger,tick}ledger::{claim_beat,ensure_beat_ledger,tick}

Boundary

Depends on no other workspace tier.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/cron
Vocabulary in force (lexicon)current

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`infrastructure-jobs`infrastructurenoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
chrono-tz^0.10noalways
cron^0.15noalways
serde^1derivenoalways
serde_json^1noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1fullnoalways
tracing^0.1noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio-test^0.4noalways

Build. None.

Depended on by. 1 workspace crate.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_tickets["application-tickets"] -->|uses| SELF
  SELF["infrastructure-cron"]
  SELF -->|runtime| n_infrastructure_jobs["infrastructure-jobs"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

No Cargo features are defined: every capability is unconditional, so no consumer can receive a half-wired crate.

Targets

KindNameSource
libinfrastructure_cron`src/lib.rs`
testbeats`tests/beats.rs`

Error model

Error typeNamed by
CronErrordue_beats_tz

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

1 workspace crate depends on this one: application-tickets.

Verification

KindCount
Unit tests10
Integration tests3
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
crate root702

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc77
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 7
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files2
Source lines460
Code lines307
Public API items7
Public modules0
Tests13
Examples0
Cargo features0
Direct runtime dependencies11
Workspace reverse dependencies1
pie showData
    title Public API by kind
    "enum" : 2
    "function" : 4
    "struct" : 1
pie showData
    title Rust source composition
    "Code" : 307
    "Blank or comment" : 153

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All infrastructure · Manual