feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
CI / Build and test (push) Successful in 7m0s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 6s
Release / Build, test and publish (push) Successful in 13m28s
CI / PostgreSQL 16 integration (push) Successful in 5m52s
CI / PostgreSQL 17 integration (push) Successful in 4m50s
CI / Docker image (push) Successful in 1m4s
Release / Server image (push) Successful in 1m35s

- Jobs > Scheduled on the desktop and the admin panel. Every timer that queued work is now a visible system schedule: archive scan, upload clean-up, index backup, job-history and audit clean-ups, desktop housekeeping. New actions: verify, thumbnails, proxies, analysis, maintenance, backup, clean-ups, reports.
- The scheduler: migration 0007, in-house recurrence, compare-and-set claim, catch-up, scan at start.
- Log settings: levels, retention, size parts, total limit, daily or hourly rotation, audit retention, diagnostics share; the server writes Debug/Trace to its files again; logging never fails a job.

Upgrade: CHRONOS_LOG_LEVEL set in an existing container locks both levels; migration 0007 is one-way.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #10.
This commit is contained in:
Alby96andClaude Opus 5.5 authored and Alby96 committed 2026-10-27 11:19:26 +01:00
1 parent 1f089888e8
commit af9eeaab9b
349 files changed
+28341 -1304

No files matched your search

+83
View File
@@ -128,6 +128,89 @@ public sealed class ManualTimeProvider : TimeProvider
public void Advance(TimeSpan by) => Interlocked.Add(ref _ticks, by.Ticks);
}
/// <summary>
/// A clock tests move by hand whose timers (<see cref="PeriodicTimer"/>, <c>Task.Delay</c>, timed cancellation) fire only
/// when <see cref="Advance"/> reaches them, never in real time: the loops paced by it run exactly when a test says.
/// </summary>
public sealed class SteppedTimeProvider : TimeProvider
{
private readonly Lock _gate = new();
private readonly List<SteppedTimer> _timers = [];
private DateTimeOffset _now = DateTimeOffset.UtcNow;
public override DateTimeOffset GetUtcNow()
{
lock (_gate) return _now;
}
public override ITimer CreateTimer(TimerCallback callback, object? state, TimeSpan dueTime, TimeSpan period)
{
var timer = new SteppedTimer(this, callback, state);
timer.Change(dueTime, period);
return timer;
}
/// <summary>Moves the clock on, then fires each timer due by then once (a periodic one moves to its next period after now).</summary>
public void Advance(TimeSpan by)
{
List<SteppedTimer> due;
lock (_gate)
{
_now += by;
due = [.. _timers.Where(t => t.Due <= _now)];
foreach (var timer in due)
{
if (timer.Period <= TimeSpan.Zero) _timers.Remove(timer);
else
{
while (timer.Due <= _now) timer.Due += timer.Period;
}
}
}
foreach (var timer in due) timer.Fire();
}
private void Schedule(SteppedTimer timer, TimeSpan dueTime, TimeSpan period)
{
lock (_gate)
{
_timers.Remove(timer);
if (dueTime == Timeout.InfiniteTimeSpan) return;
timer.Due = _now + dueTime;
timer.Period = period == Timeout.InfiniteTimeSpan ? TimeSpan.Zero : period;
_timers.Add(timer);
}
}
private void Remove(SteppedTimer timer)
{
lock (_gate) _timers.Remove(timer);
}
private sealed class SteppedTimer(SteppedTimeProvider clock, TimerCallback callback, object? state) : ITimer
{
public DateTimeOffset Due { get; set; }
public TimeSpan Period { get; set; }
public bool Change(TimeSpan dueTime, TimeSpan period)
{
clock.Schedule(this, dueTime, period);
return true;
}
public void Fire() => callback(state);
public void Dispose() => clock.Remove(this);
public ValueTask DisposeAsync()
{
Dispose();
return ValueTask.CompletedTask;
}
}
}
/// <summary>
/// A job handler that reports progress and then waits until <see cref="Release"/> (or cancellation), so tests can
/// observe running, paused and cancelled states.