Files
Chronos/src/Chronos.Protocol/Schedules.cs
T
Alby96andClaude Opus 5.5 af9eeaab9b
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
feat: owner review 2 phase 2: scheduled jobs and log settings (#10)
- 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>
2026-10-27 11:19:26 +01:00

98 lines
4.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
namespace Chronos.Protocol;
/// <summary>
/// The parameters of a schedule's action (owner review 2, R10), flat: each action reads its own fields, the others stay
/// null (and are not stored). <c>scan</c>: <see cref="Force"/> (full scan), <see cref="Deep"/> (background deep analysis of
/// what it indexes). <c>verify</c>: <see cref="OlderThanDays"/> (only sequences not verified for that many days; 0: any),
/// <see cref="Percent"/> (share of the archive's sequences per run, least recently verified first). <c>thumbnails</c>,
/// <c>proxies</c>: <see cref="Force"/> (make again those already made). <c>analysis</c>: <see cref="Deep"/> (deep instead of
/// light). <c>maintenance</c>: <see cref="DryRun"/>. <c>backup</c>: <see cref="Keep"/> (copies kept). <c>cleanup</c>:
/// <see cref="Steps"/> (step names) and <see cref="OlderThanDays"/> (what is older goes; 0 keeps everything).
/// <c>duplicates</c>, <c>orphans</c>: none.
/// </summary>
public sealed record ScheduleParametersDto(
int? OlderThanDays = null,
int? Percent = null,
bool? Deep = null,
bool? DryRun = null,
bool? Force = null,
IReadOnlyList<string>? Steps = null,
int? Keep = null);
/// <summary>
/// When a schedule fires, structured. <see cref="Kind"/> = <c>every</c> (<see cref="Every"/> and <see cref="Unit"/>:
/// <c>minutes</c>, <c>hours</c> or <c>days</c>; at least 5 minutes), <c>daily</c> (<see cref="Time"/>), <c>weekly</c>
/// (<see cref="Days"/>: <c>mon</c> … <c>sun</c>; <see cref="Time"/>) or <c>monthly</c> (<see cref="DayOfMonth"/> 1–28;
/// <see cref="Time"/>). <see cref="Time"/> is <c>HH:MM</c>, wall-clock time of the host's time zone.
/// </summary>
public sealed record RecurrenceDto(
string Kind,
int? Every = null,
string? Unit = null,
string? Time = null,
IReadOnlyList<string>? Days = null,
int? DayOfMonth = null);
/// <summary>
/// A schedule (owner review 2, R10). <see cref="SystemKey"/> is set on the host's system schedules (the timers it runs,
/// shown so nothing runs out of sight): they can be edited, disabled and reset, never deleted. <see cref="Priority"/> is the
/// priority of the jobs it queues (<c>background</c>, <c>normal</c>, <c>user</c>). <see cref="LastOutcome"/>:
/// <c>queued</c>, <c>skipped-pending</c>, <c>skipped-offline</c>, <c>skipped-nothing</c>, <c>unavailable</c> or
/// <c>failed:&lt;reason&gt;</c>. <see cref="NextRun"/> is null while the schedule is disabled.
/// </summary>
public sealed record ScheduleDto(
Guid Id,
string? SystemKey,
string Name,
string Action,
string Target,
ScheduleParametersDto Parameters,
RecurrenceDto Recurrence,
bool CatchUp,
string Priority,
bool Enabled,
DateTimeOffset? NextRun,
DateTimeOffset? LastRun,
Guid? LastJobId,
string? LastOutcome,
Guid? CreatedBy,
DateTimeOffset Created,
DateTimeOffset Updated);
/// <summary>An action a schedule can take and whether this host runs it; <see cref="Reason"/> says why not (a code: <c>no-handler</c>, <c>postgres</c>, <c>proxies-disabled</c>…).</summary>
public sealed record ScheduleActionDto(string Name, bool Available, string? Reason);
/// <summary>
/// <c>GET /api/v1/schedules</c>: the schedules, system ones first, the actions with their availability, the host's time
/// zone (IANA or Windows id, as the host names it) and the clean-up steps its <c>cleanup</c> action runs.
/// </summary>
public sealed record SchedulesDto(IReadOnlyList<ScheduleDto> Items, IReadOnlyList<ScheduleActionDto> Actions, string TimeZone,
IReadOnlyList<string>? Steps = null);
/// <summary><c>POST /api/v1/schedules</c>: a new schedule; <see cref="Target"/> defaults to <c>current</c>, <see cref="Priority"/> to <c>background</c>.</summary>
public sealed record CreateScheduleRequest(
string Name,
string Action,
RecurrenceDto Recurrence,
ScheduleParametersDto? Parameters = null,
bool CatchUp = true,
string? Priority = null,
bool Enabled = true,
string? Target = null);
/// <summary>
/// <c>PATCH /api/v1/schedules/{id}</c>: the fields given replace the stored ones (<see cref="Parameters"/> as a whole). A
/// system schedule keeps its name and action.
/// </summary>
public sealed record UpdateScheduleRequest(
string? Name = null,
string? Action = null,
RecurrenceDto? Recurrence = null,
ScheduleParametersDto? Parameters = null,
bool? CatchUp = null,
string? Priority = null,
bool? Enabled = null);
/// <summary><c>POST /api/v1/schedules/{id}/run</c>: what running the schedule now did, and the schedule afterwards.</summary>
public sealed record ScheduleRunDto(ScheduleDto Schedule, string Outcome, Guid? JobId);