Adds scheduled job contracts and application handlers

This commit is contained in:
BinaryAlley committed 2026-09-03 12:48:53 -07:00
1 parent 7fbb4dc0d3
commit ea7e003bff
51 files changed
+2442

No files matched your search

@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to add a scheduled job.
/// </summary>
/// <param name="Name">The name of the scheduled job. Required.</param>
/// <param name="TaskType">The type of the task executed by the scheduled job. Required.</param>
/// <param name="ScheduleType">The type of the schedule of the scheduled job. Required.</param>
/// <param name="IntervalMinutes">The interval in minutes of the schedule, required when <paramref name="ScheduleType"/> is <see cref="ScheduleType.WithIntervalInMinutes"/>.</param>
/// <param name="Hour">The hour of the schedule, required when <paramref name="ScheduleType"/> is <see cref="ScheduleType.DailyAtHourAndMinute"/>.</param>
/// <param name="Minute">The minute of the schedule, required when <paramref name="ScheduleType"/> is <see cref="ScheduleType.DailyAtHourAndMinute"/>.</param>
[DebuggerDisplay("Name: {Name}")]
public record AddScheduledJobRequest(
string Name,
ScheduledTaskType TaskType,
ScheduleType ScheduleType,
int? IntervalMinutes,
int? Hour,
int? Minute
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to fire the task of a scheduled job once, without affecting its execution cycle.
/// </summary>
/// <param name="ScheduledJobId">The unique identifier of the scheduled job whose task is fired. Required.</param>
[DebuggerDisplay("ScheduledJobId: {ScheduledJobId}")]
public record FireScheduledJobRequest(
Guid ScheduledJobId
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to get the history of the executions of the tasks of scheduled jobs.
/// </summary>
/// <param name="From">The inclusive lower bound of the interval for which the history is requested. Optional.</param>
/// <param name="To">The inclusive upper bound of the interval for which the history is requested. Optional.</param>
[DebuggerDisplay("From: {From}, To: {To}")]
public record GetScheduledJobHistoryRequest(
DateTime? From,
DateTime? To
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to remove a scheduled job.
/// </summary>
/// <param name="ScheduledJobId">The unique identifier of the scheduled job to remove. Required.</param>
[DebuggerDisplay("ScheduledJobId: {ScheduledJobId}")]
public record RemoveScheduledJobRequest(
Guid ScheduledJobId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to start the execution cycle of a scheduled job.
/// </summary>
/// <param name="ScheduledJobId">The unique identifier of the scheduled job whose execution cycle is started. Required.</param>
[DebuggerDisplay("ScheduledJobId: {ScheduledJobId}")]
public record StartScheduledJobRequest(
Guid ScheduledJobId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Scheduling;
/// <summary>
/// Represents a request to stop the execution cycle of a scheduled job.
/// </summary>
/// <param name="ScheduledJobId">The unique identifier of the scheduled job whose execution cycle is stopped. Required.</param>
[DebuggerDisplay("ScheduledJobId: {ScheduledJobId}")]
public record StopScheduledJobRequest(
Guid ScheduledJobId
);
@@ -0,0 +1,26 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.Scheduling;
/// <summary>
/// Represents an execution of the task of a scheduled job.
/// </summary>
/// <param name="Id">The unique identifier of the execution.</param>
/// <param name="ScheduledJobId">The unique identifier of the scheduled job whose task was executed.</param>
/// <param name="TaskType">The type of the task that was executed.</param>
/// <param name="IsCycleRun"><see langword="true"/> when the execution was triggered by the execution cycle of the scheduled job, <see langword="false"/> when it was a one time execution.</param>
/// <param name="StartedOnUtc">The date and time when the execution started.</param>
/// <param name="CompletedOnUtc">The optional date and time when the execution completed.</param>
[DebuggerDisplay("Id: {Id}, ScheduledJobId: {ScheduledJobId}")]
public record ScheduledJobExecutionResponse(
Guid Id,
Guid ScheduledJobId,
ScheduledTaskType TaskType,
bool IsCycleRun,
DateTime StartedOnUtc,
DateTime? CompletedOnUtc
);
@@ -0,0 +1,34 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.SharedKernel.Common.Enums.Scheduling;
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.Scheduling;
/// <summary>
/// Represents a scheduled job response.
/// </summary>
/// <param name="Id">The unique identifier of the scheduled job.</param>
/// <param name="Name">The name of the scheduled job.</param>
/// <param name="TaskType">The type of the task executed by the scheduled job.</param>
/// <param name="ScheduleType">The type of the schedule of the scheduled job.</param>
/// <param name="IntervalMinutes">The interval in minutes of the schedule of the scheduled job, when its <see cref="ScheduleType"/> is <see cref="ScheduleType.WithIntervalInMinutes"/>.</param>
/// <param name="Hour">The hour of the schedule of the scheduled job, when its <see cref="ScheduleType"/> is <see cref="ScheduleType.DailyAtHourAndMinute"/>.</param>
/// <param name="Minute">The minute of the schedule of the scheduled job, when its <see cref="ScheduleType"/> is <see cref="ScheduleType.DailyAtHourAndMinute"/>.</param>
/// <param name="Status">The status of the scheduled job.</param>
/// <param name="LastStartedOnUtc">The optional date and time when the task of the scheduled job last started its execution.</param>
/// <param name="LastCompletedOnUtc">The optional date and time when the task of the scheduled job last completed its execution.</param>
[DebuggerDisplay("Id: {Id}, Name: {Name}, Status: {Status}")]
public record ScheduledJobResponse(
Guid Id,
string Name,
ScheduledTaskType TaskType,
ScheduleType ScheduleType,
int? IntervalMinutes,
int? Hour,
int? Minute,
ScheduledJobStatus Status,
DateTime? LastStartedOnUtc,
DateTime? LastCompletedOnUtc
);