| | | 1 | | namespace ArturRios.Heimdall.WebApi.Retention; |
| | | 2 | | |
| | | 3 | | /// <summary>What one run of a <see cref="ScheduledPassService" /> pass did.</summary> |
| | | 4 | | /// <param name="Summary"> |
| | | 5 | | /// The line to log: the outcome of a run that changed something, the errors of one that failed, or |
| | | 6 | | /// <c>null</c> for a clean run with nothing worth saying. |
| | | 7 | | /// </param> |
| | | 8 | | /// <param name="Failed"> |
| | | 9 | | /// Whether the pass's command reported failure. A failed run is logged at Error with |
| | | 10 | | /// <see cref="ScheduledPassService.FailureMarker" /> and does not count as a success. |
| | | 11 | | /// </param> |
| | | 12 | | /// <param name="RowsProcessed">The rows the pass reports having changed, for the rows-processed counter.</param> |
| | 94 | 13 | | public sealed record ScheduledPassResult(string? Summary, bool Failed = false, long RowsProcessed = 0) |
| | | 14 | | { |
| | | 15 | | /// <summary>A run that did nothing worth reporting.</summary> |
| | 1 | 16 | | public static ScheduledPassResult Quiet => new(null, false); |
| | | 17 | | |
| | | 18 | | /// <summary> |
| | | 19 | | /// A failed run, described by the command's errors, with the rows it changed before it failed — |
| | | 20 | | /// a pass that drains in batches (#206) may have finished several before one failed. |
| | | 21 | | /// </summary> |
| | | 22 | | public static ScheduledPassResult Failure(string summary, IEnumerable<string> errors, long rowsProcessed = 0) => |
| | 6 | 23 | | new( |
| | 6 | 24 | | $"{summary} failed: {string.Join("; ", errors)}" + |
| | 6 | 25 | | (rowsProcessed > 0 ? $". It had processed {rowsProcessed} rows before failing" : ""), |
| | 6 | 26 | | true, rowsProcessed); |
| | | 27 | | } |