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
@@ -185,7 +185,7 @@ public sealed class SampleData
|
||||
{
|
||||
var db = _db ?? throw new InvalidOperationException("FillAsync first.");
|
||||
var service = _services.Sync.Service ?? throw new InvalidOperationException("The index is not open.");
|
||||
// The history is kept whatever the date: the sample's finished jobs are dated from Now, not from today.
|
||||
// The engine purges no history (the housekeeping schedule does): the sample's finished jobs, dated from Now, stay.
|
||||
await using var engine = new JobEngine(db, service.CreateJobHandlers(_services.Sync),
|
||||
new JobEngineOptions
|
||||
{
|
||||
@@ -193,7 +193,6 @@ public sealed class SampleData
|
||||
WorkerId = "sample-proxies",
|
||||
Kinds = [JobKind.Download],
|
||||
PollInterval = TimeSpan.FromMilliseconds(50),
|
||||
HistoryRetention = TimeSpan.FromDays(36_500),
|
||||
});
|
||||
await engine.StartAsync();
|
||||
var job = await service.EnqueueDownloadAsync(engine, ServerAddress, _sunrise, "Sunrise over Superga", SyncDownloadMode.Proxies, null);
|
||||
|
||||
@@ -39,9 +39,12 @@ public static class JobNotices
|
||||
kind is JobKind.Render or JobKind.DeepAnalyse or JobKind.Verify or JobKind.Rebuild or JobKind.Maintenance or JobKind.UploadCommit
|
||||
or JobKind.Move or JobKind.Adopt;
|
||||
|
||||
/// <summary>Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing.</summary>
|
||||
/// <summary>
|
||||
/// Work that keeps the index and its previews current: the next run repeats it, the Archive screen shows what is missing.
|
||||
/// Clean-ups too: the housekeeping schedule runs them again (a failed index backup is said).
|
||||
/// </summary>
|
||||
private static bool IsUpkeep(JobKind kind) =>
|
||||
kind is JobKind.Scan or JobKind.Thumbs or JobKind.Proxies or JobKind.LightAnalyse;
|
||||
kind is JobKind.Scan or JobKind.Thumbs or JobKind.Proxies or JobKind.LightAnalyse or JobKind.Cleanup;
|
||||
}
|
||||
|
||||
/// <summary>Endings said in one toast: one job, or several of a batch.</summary>
|
||||
|
||||
@@ -141,8 +141,8 @@ public sealed class JobsViewModel : SectionViewModel
|
||||
/// <summary>The priority queue of Settings › Rendering is on: higher jobs pause the running one.</summary>
|
||||
public bool IsPriorityQueueOn => HasEngine && Shell.Services.Settings.PriorityQueue;
|
||||
|
||||
/// <summary>"History keeps 90 days".</summary>
|
||||
public string HistoryText => Loc.Plural("Jobs.History", (long)new JobEngineOptions().HistoryRetention.TotalDays);
|
||||
/// <summary>"History keeps 90 days": the job-history step of the housekeeping schedule.</summary>
|
||||
public string HistoryText => Loc.Plural("Jobs.History", (long)Chronos.Data.Housekeeping.CleanupSteps.DefaultHistoryDays);
|
||||
|
||||
public bool IsEmpty => _hasLoaded && Rows.Count == 0;
|
||||
|
||||
|
||||
@@ -1147,6 +1147,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
[
|
||||
JobKind.Render, JobKind.Import, JobKind.Download, JobKind.UploadCommit, JobKind.Scan, JobKind.Rebuild, JobKind.Verify, JobKind.LightAnalyse,
|
||||
JobKind.DeepAnalyse, JobKind.Thumbs, JobKind.Proxies, JobKind.Maintenance, JobKind.Duplicates, JobKind.Orphans, JobKind.Adopt, JobKind.Move,
|
||||
JobKind.Backup, JobKind.Cleanup,
|
||||
];
|
||||
|
||||
/// <summary>Stores <paramref name="level"/> for <paramref name="kind"/>, keeping only the levels that differ from the defaults.</summary>
|
||||
|
||||
Reference in new issue
Block a user