-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIScheduleBuilder.cs
50 lines (44 loc) · 2.34 KB
/
IScheduleBuilder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
namespace Sa.Schedule;
public interface IScheduleBuilder
{
/// <summary>
/// Adds a job of type <typeparamref name="T"/> to the schedule.
/// </summary>
/// <typeparam name="T">The type of job to add.</typeparam>
/// <param name="jobId">The ID of the job. If not specified, a new ID will be generated.</param>
/// <returns>A builder for the added job.</returns>
IJobBuilder AddJob<T>(Guid? jobId = null) where T : class, IJob;
/// <summary>
/// Adds a job with the specified action to the schedule.
/// </summary>
/// <param name="action">The action to execute when the job is run.</param>
/// <param name="jobId">The ID of the job. If not specified, a new ID will be generated.</param>
/// <returns>A builder for the added job.</returns>
IJobBuilder AddJob(Func<IJobContext, CancellationToken, Task> action, Guid? jobId = null);
/// <summary>
/// Adds a job of type <typeparamref name="T"/> to the schedule and configures it using the specified action.
/// </summary>
/// <typeparam name="T">The type of job to add.</typeparam>
/// <param name="configure">An action to configure the job.</param>
/// <param name="jobId">The ID of the job. If not specified, a new ID will be generated.</param>
/// <returns>The schedule builder.</returns>
IScheduleBuilder AddJob<T>(Action<IServiceProvider, IJobBuilder> configure, Guid? jobId = null) where T : class, IJob;
/// <summary>
/// Adds an interceptor of type <typeparamref name="T"/> to the schedule.
/// </summary>
/// <typeparam name="T">The type of interceptor to add.</typeparam>
/// <param name="key">The key to use for the interceptor. If not specified, a default key will be used.</param>
/// <returns>The schedule builder.</returns>
IScheduleBuilder AddInterceptor<T>(object? key = null) where T : class, IJobInterceptor;
/// <summary>
/// Configures the schedule to use a hosted service.
/// </summary>
/// <returns>The schedule builder.</returns>
IScheduleBuilder UseHostedService();
/// <summary>
/// Adds an error handler to the schedule.
/// </summary>
/// <param name="handler">A function to handle errors that occur during job execution.</param>
/// <returns>The schedule builder.</returns>
IScheduleBuilder AddErrorHandler(Func<IJobContext, Exception, bool> handler);
}