Add cron-based autonomous workflow firing with two hardening layers:
- Timezone-aware scheduling via chrono-tz: ScheduledWorkflow.timezone
(IANA identifier), compute_next_fire_at/after_tz, validate_timezone;
DST-safe, UTC fallback when absent; validated at config load and REST API
- Distributed fire-lock via SurrealDB conditional UPDATE (locked_by/locked_at
fields, 120 s TTL); WorkflowScheduler gains instance_id (UUID) as lock owner;
prevents double-fires across multi-instance deployments without extra infra
- ScheduleStore: try_acquire_fire_lock, release_fire_lock (own-instance guard),
full CRUD (load_one/all, full_upsert, patch, delete, load_runs)
- REST: 7 endpoints (GET/PUT/PATCH/DELETE schedules, runs history, manual fire)
with timezone field in all request/response types
- Migrations 010 (schedule tables) + 011 (timezone + lock columns)
- Tests: 48 passing (was 26); ADR-0034; changelog; feature docs updated
10 lines
657 B
Plaintext
10 lines
657 B
Plaintext
-- Migration 011: Timezone and Distributed Fire-Lock for Scheduled Workflows
|
|
-- Extends the scheduled_workflows table with:
|
|
-- timezone — IANA timezone identifier for cron evaluation (e.g. "America/New_York")
|
|
-- locked_by — instance UUID holding the current fire lock (prevents double-fires)
|
|
-- locked_at — when the lock was acquired; TTL = 120 s is enforced in application code
|
|
|
|
DEFINE FIELD timezone ON TABLE scheduled_workflows TYPE option<string> DEFAULT NONE;
|
|
DEFINE FIELD locked_by ON TABLE scheduled_workflows TYPE option<string> DEFAULT NONE;
|
|
DEFINE FIELD locked_at ON TABLE scheduled_workflows TYPE option<datetime> DEFAULT NONE;
|