| | | 1 | | namespace Kestrun.Tasks; |
| | | 2 | | |
| | | 3 | | /// <summary> |
| | | 4 | | /// Basic information about a task for listing purposes. |
| | | 5 | | /// </summary> |
| | | 6 | | /// <param name="Id">Unique task identifier.</param> |
| | | 7 | | /// <param name="Name">Optional human-friendly name of the task.</param> |
| | | 8 | | /// <param name="Description">Optional description of the task.</param> |
| | | 9 | | /// <param name="State">Final state of the task when the result was captured.</param> |
| | | 10 | | /// <param name="StartedAt">UTC timestamp when execution started.</param> |
| | | 11 | | /// <param name="CompletedAt">UTC timestamp when execution ended.</param> |
| | | 12 | | /// <param name="Progress">Optional progress state of the task.</param> |
| | | 13 | | /// <param name="ParentId">Optional identifier of the parent task, if any.</param> |
| | | 14 | | /// <param name="ChildrenId">Identifiers of any child tasks spawned by this task.</param> |
| | 7 | 15 | | public record KrTask( |
| | 5 | 16 | | string Id, |
| | 2 | 17 | | string Name, |
| | 2 | 18 | | string Description, |
| | 0 | 19 | | TaskState State, |
| | 0 | 20 | | DateTimeOffset? StartedAt, |
| | 0 | 21 | | DateTimeOffset? CompletedAt, |
| | 6 | 22 | | ProgressiveKestrunTaskState? Progress, |
| | 0 | 23 | | string ParentId, |
| | 0 | 24 | | string[] ChildrenId |
| | 7 | 25 | | ) |
| | | 26 | | { |
| | | 27 | | /// <summary> |
| | | 28 | | /// The textual name of <see cref="State"/> for display and serialization convenience. |
| | | 29 | | /// </summary> |
| | 0 | 30 | | public string StateText => State.ToString(); |
| | | 31 | | |
| | | 32 | | /// <summary> |
| | | 33 | | /// Duration of the execution, if both timestamps are available. |
| | | 34 | | /// </summary> |
| | 0 | 35 | | public TimeSpan? Duration => (StartedAt.HasValue && CompletedAt.HasValue) |
| | 0 | 36 | | ? CompletedAt.Value - StartedAt.Value |
| | 0 | 37 | | : null; |
| | | 38 | | } |