-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
PartitionInitializingEventArgs.cs
67 lines (61 loc) · 3.09 KB
/
PartitionInitializingEventArgs.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
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System.Threading;
using Azure.Core;
using Azure.Messaging.EventHubs.Consumer;
namespace Azure.Messaging.EventHubs.Processor
{
/// <summary>
/// Contains information about a partition that an <c>EventProcessorClient</c> will be
/// processing events from. It can also be used to specify the position within a partition
/// where the associated <c>EventProcessorClient</c> should begin reading events in case
/// it cannot find a checkpoint.
/// </summary>
///
/// <seealso href="https://www.nuget.org/packages/Azure.Messaging.EventHubs.Processor">Azure.Messaging.EventHubs.Processor (NuGet)</seealso>
///
public class PartitionInitializingEventArgs
{
/// <summary>
/// The identifier of the partition whose processing is starting.
/// </summary>
///
public string PartitionId { get; }
/// <summary>
/// The position within a partition where the associated <c>EventProcessorClient</c> should
/// begin reading events when no checkpoint can be found.
/// </summary>
///
public EventPosition DefaultStartingPosition { get; set; }
/// <summary>
/// A <see cref="System.Threading.CancellationToken"/> indicate that the processor is requesting that the handler
/// stop its activities. If this token is requesting cancellation, then either the processor is attempting to
/// shutdown or ownership of the partition has changed.
/// </summary>
///
/// <remarks>
/// The handler for initialization has responsibility for deciding whether or not to honor
/// the cancellation request. If the application chooses not to do so, the processor will wait for the
/// handler to complete before taking further action.
/// </remarks>
///
public CancellationToken CancellationToken { get; }
/// <summary>
/// Initializes a new instance of the <see cref="PartitionInitializingEventArgs"/> class.
/// </summary>
///
/// <param name="partitionId">The identifier of the partition whose processing is starting.</param>
/// <param name="defaultStartingPosition">The position within a partition where the associated <c>EventProcessorClient</c> should begin reading events when no checkpoint can be found.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> instance to signal the request to cancel the operation.</param>
///
public PartitionInitializingEventArgs(string partitionId,
EventPosition defaultStartingPosition,
CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(partitionId, nameof(partitionId));
PartitionId = partitionId;
DefaultStartingPosition = defaultStartingPosition;
CancellationToken = cancellationToken;
}
}
}