feat(data): scheduler engine, schedules table and housekeeping jobs
Owner review 2, R10: every timer that queues work becomes a visible schedule, so the server and the desktop need one shared engine to run them. - Migration 0007: schedules table (system rows keyed by system_key) and jobs.schedule_id; Job.ScheduleId, JobDto.ScheduleId, JobRepository HasPendingAsync / ListPendingTargetsAsync / ListByScheduleAsync. - ScheduleRepository: seeding that keeps user edits, reset, compare-and-set claim of a run (one winner across processes), outcomes. - Scheduling: in-house recurrence (every/daily/weekly/monthly, DST gap moves forward, ambiguous time runs once), ScheduleActions resolving scan, verify, thumbnails, proxies, analysis, maintenance, backup, cleanup, duplicates and orphans into archive jobs, IScheduleHost, and the Scheduler loop (catch-up, clock going back, run now, CRUD as API v1 DTOs). - New job kinds Backup (16) and Cleanup (17) with handlers, shared clean-up steps (job history, audit log, trash report that never deletes) and host steps through ArchiveServiceOptions; read-only Duplicates and Orphans report handlers, so the server can run those kinds too. - JobEngine no longer purges history at start: the housekeeping schedule's job-history step does; JobEngine.CanRun and an EnqueueAsync with scheduleId. - Protocol DTOs for schedules; job kind names in en and it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> (cherry picked from commit eb0edd2483a493db7c6945d5b494461cabb2a4ad)
This commit is contained in:
1 parent
0e84392f4f
commit
e5508e7e69
51 files changed
+3219
-30
No files matched your search
@@ -0,0 +1,27 @@
|
||||
-- Scheduled jobs (owner review 2, R10): one row per schedule, the timers a host used to run out of sight included as
|
||||
-- system schedules (system_key set, seeded by the host at start, never here). next_run is claimed by compare-and-set,
|
||||
-- so one process fires each run. Jobs remember the schedule that queued them. Mirrors sqlite/0007_schedules.sql.
|
||||
|
||||
CREATE TABLE schedules (
|
||||
id uuid NOT NULL PRIMARY KEY,
|
||||
system_key text COLLATE "C" UNIQUE,
|
||||
name text NOT NULL,
|
||||
action text NOT NULL,
|
||||
target text NOT NULL DEFAULT 'current',
|
||||
parameters_json jsonb,
|
||||
recurrence text NOT NULL,
|
||||
catch_up boolean NOT NULL DEFAULT TRUE,
|
||||
priority integer NOT NULL DEFAULT 0,
|
||||
enabled boolean NOT NULL DEFAULT TRUE,
|
||||
next_run timestamptz,
|
||||
last_run timestamptz,
|
||||
last_job_id uuid,
|
||||
last_outcome text,
|
||||
created_by uuid,
|
||||
created timestamptz NOT NULL,
|
||||
updated timestamptz NOT NULL
|
||||
);
|
||||
CREATE INDEX ix_schedules_due ON schedules (enabled, next_run);
|
||||
|
||||
ALTER TABLE jobs ADD COLUMN schedule_id uuid;
|
||||
CREATE INDEX ix_jobs_schedule ON jobs (schedule_id, created);
|
||||
@@ -0,0 +1,27 @@
|
||||
-- Scheduled jobs (owner review 2, R10): one row per schedule, the timers a host used to run out of sight included as
|
||||
-- system schedules (system_key set, seeded by the host at start, never here). next_run is claimed by compare-and-set,
|
||||
-- so one process fires each run. Jobs remember the schedule that queued them. Mirrors postgres/0007_schedules.sql.
|
||||
|
||||
CREATE TABLE schedules (
|
||||
id TEXT NOT NULL PRIMARY KEY,
|
||||
system_key TEXT UNIQUE,
|
||||
name TEXT NOT NULL,
|
||||
action TEXT NOT NULL,
|
||||
target TEXT NOT NULL DEFAULT 'current',
|
||||
parameters_json TEXT,
|
||||
recurrence TEXT NOT NULL,
|
||||
catch_up INTEGER NOT NULL DEFAULT 1,
|
||||
priority INTEGER NOT NULL DEFAULT 0,
|
||||
enabled INTEGER NOT NULL DEFAULT 1,
|
||||
next_run TEXT,
|
||||
last_run TEXT,
|
||||
last_job_id TEXT,
|
||||
last_outcome TEXT,
|
||||
created_by TEXT,
|
||||
created TEXT NOT NULL,
|
||||
updated TEXT NOT NULL
|
||||
);
|
||||
CREATE INDEX ix_schedules_due ON schedules (enabled, next_run);
|
||||
|
||||
ALTER TABLE jobs ADD COLUMN schedule_id TEXT;
|
||||
CREATE INDEX ix_jobs_schedule ON jobs (schedule_id, created);
|
||||
Reference in new issue
Block a user