-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTaskProcessorOptions.cs
More file actions
80 lines (64 loc) · 2.78 KB
/
Copy pathTaskProcessorOptions.cs
File metadata and controls
80 lines (64 loc) · 2.78 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
namespace Core.TaskProcessor;
public class TaskProcessorOptions
{
/// <summary>
/// redis prefix for all keys and channels
/// cluster mode requires hash notation e.g. {taskproc-1}
/// </summary>
public string Prefix { get; set; } = string.Empty;
/// <summary>
/// queues to listen for, order determines priority
/// </summary>
public string[] Queues { get; set; } = { "default" };
/// <summary>
/// max concurrent work on all queues for this instance
/// </summary>
public int MaxWorkers { get; set; } = Environment.ProcessorCount;
/// <summary>
/// main loop frequency
/// fetches tasks when reactive events failed
/// </summary>
public TimeSpan BaseFrequency { get; set; } = TimeSpan.FromSeconds(5);
/// <summary>
/// within base frequency how often to run batch cleanups
/// </summary>
public TimeSpan CleanUpFrequency { get; set; } = TimeSpan.FromMinutes(5);
/// <summary>
/// within base frequency how often to run task pushbacks
/// </summary>
public TimeSpan PushbackFrequency { get; set; } = TimeSpan.FromSeconds(10);
/// <summary>
/// how long batches are kept
/// </summary>
public TimeSpan Retention { get; set; } = TimeSpan.FromDays(14);
/// <summary>
/// if tasks failed this many times they will be discarded or deadlettered
/// </summary>
public int Retries { get; set; } = 3;
/// <summary>
/// when retries are exhausted move to deadletter list instead of discard
/// </summary>
public bool Deadletter { get; set; } = true;
/// <summary>
/// when retries are exhausted on unique schedules they will never run again until task removed
/// </summary>
public bool DeadletterSchedules { get; set; } = false;
/// <summary>
/// deduplication window
/// </summary>
public TimeSpan Invisibility { get; set; } = TimeSpan.FromMinutes(5);
public Func<TaskContext, Task> OnTaskStart { get; set; } = _ => Task.CompletedTask;
public Func<TaskContext, Task> OnTaskEnd { get; set; } = _ => Task.CompletedTask;
public Func<TaskContext, Exception, Task> OnTaskError { get; set; } = (_, _) => Task.CompletedTask;
public string Redis { get; set; } = string.Empty;
//public bool UseHostedService { get; set; }
public bool UseCronSeconds { get; set; }
public IRemoteExpressionExecutor ExpressionExecutor { get; set; } = new RemoteExpressionExecutor();
/// <summary>
/// when tasks throws exception delay re-enqueue until TimeSpan
/// number of retries left
/// null = instant (default)
/// </summary>
public Func<TaskContext, long, Task<TimeSpan?>> OnTaskFailedDelay { get; set; } =
(_, _) => Task.FromResult<TimeSpan?>(null);
}