Skip to main content

Crate vigy_runtime

Crate vigy_runtime 

Source
Expand description

Tokio-driven tick scheduler + registry for vigies.

§Topology

                ┌──────────────────────────┐
                │  RuntimeHandle (Clone)   │  ← public surface used by
                └────────────┬─────────────┘    vigy-cli / vigy-rpc /
                             │                  vigy-graphql / vigy-rest
                             ▼
                ┌──────────────────────────┐
                │      Inner (Arc'd)       │
                │  - store: Store          │
                │  - tasks: Mutex<HashMap> │
                │  - bus:   broadcast tx   │
                └────────────┬─────────────┘
                             │ spawn per-vigy
                             ▼
    ┌─────────────────────────────────────────────┐
    │  tick_loop(vigy_id) — one tokio task each   │
    │  loop {                                      │
    │    sleep(interval).                          │
    │    evaluate(vigy.program, fresh host).       │
    │    persist VigyRun.                          │
    │    broadcast to bus.                         │
    │    backoff on error.                         │
    │  }                                           │
    └─────────────────────────────────────────────┘

§Invariants

  • One task per vigy. register_or_update cancels the old task before spawning the new one, so there’s no double-tick risk.
  • Backoff on errors. Three failing ticks in a row → cap at 30s sleep until a tick succeeds.
  • Store is source of truth. On startup, RuntimeHandle::open reads existing vigies from the store and spawns tasks for the enabled ones.

Structs§

RuntimeHandle
Public, cheaply-cloneable handle. All API surfaces drive the runtime through this — no direct access to internals.

Enums§

RuntimeError

Type Aliases§

Result