-
Notifications
You must be signed in to change notification settings - Fork 38
/
SubscriptionFilterOptions.cs
54 lines (49 loc) · 2.06 KB
/
SubscriptionFilterOptions.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
51
52
53
54
namespace EventStore.Client {
/// <summary>
/// A class representing the options to use when filtering read operations.
/// </summary>
public class SubscriptionFilterOptions {
/// <summary>
/// The <see cref="IEventFilter"/> to apply.
/// </summary>
public IEventFilter Filter { get; }
/// <summary>
/// Sets how often the checkpointReached callback is called.
/// </summary>
public uint CheckpointInterval { get; }
/// <summary>
/// A Task invoked and await when a checkpoint is reached.
/// Set the checkpointInterval to define how often this method is called.
/// </summary>
public Func<StreamSubscription, Position, CancellationToken, Task> CheckpointReached { get; } = null!;
/// <summary>
///
/// </summary>
/// <param name="filter">The <see cref="IEventFilter"/> to apply.</param>
/// <param name="checkpointInterval">Sets how often the checkpointReached callback is called.</param>
/// <param name="checkpointReached">
/// A Task invoked and await when a checkpoint is reached.
/// Set the checkpointInterval to define how often this method is called.
/// </param>
/// <exception cref="ArgumentNullException"></exception>
public SubscriptionFilterOptions(IEventFilter filter, uint checkpointInterval,
Func<StreamSubscription, Position, CancellationToken, Task>? checkpointReached)
: this(filter, checkpointInterval) {
CheckpointReached = checkpointReached ?? ((_, __, ct) => Task.CompletedTask);
}
/// <summary>
///
/// </summary>
/// <param name="filter">The <see cref="IEventFilter"/> to apply.</param>
/// <param name="checkpointInterval">Sets how often the checkpointReached callback is called.</param>
/// <exception cref="ArgumentNullException"></exception>
public SubscriptionFilterOptions(IEventFilter filter, uint checkpointInterval = 1) {
if (checkpointInterval == 0) {
throw new ArgumentOutOfRangeException(nameof(checkpointInterval),
checkpointInterval, $"{nameof(checkpointInterval)} must be greater than 0.");
}
Filter = filter;
CheckpointInterval = checkpointInterval;
}
}
}