| | | 1 | | // Copyright (c) Microsoft. All rights reserved. |
| | | 2 | | // Licensed under the MIT license. See LICENSE file in the project root for full license information. |
| | | 3 | | |
| | | 4 | | namespace Microsoft.Azure.EventHubs.Processor |
| | | 5 | | { |
| | | 6 | | /// <summary> |
| | | 7 | | /// The context object used to preserve state in the stream. |
| | | 8 | | /// </summary> |
| | | 9 | | public class Checkpoint |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Creates a new Checkpoint for a particular partition ID. |
| | | 13 | | /// </summary> |
| | | 14 | | /// <param name="partitionId">The partition ID for the checkpoint</param> |
| | | 15 | | public Checkpoint(string partitionId) |
| | 0 | 16 | | : this(partitionId, EventPosition.FromStart().Offset, 0) |
| | | 17 | | { |
| | 0 | 18 | | } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// Creates a new Checkpoint for a particular partition ID, with the offset and sequence number. |
| | | 22 | | /// </summary> |
| | | 23 | | /// <param name="partitionId">The partition ID for the checkpoint</param> |
| | | 24 | | /// <param name="offset">The offset for the last processed <see cref="EventData"/></param> |
| | | 25 | | /// <param name="sequenceNumber">The sequence number of the last processed <see cref="EventData"/></param> |
| | 0 | 26 | | public Checkpoint(string partitionId, string offset, long sequenceNumber) |
| | | 27 | | { |
| | 0 | 28 | | this.PartitionId = partitionId; |
| | 0 | 29 | | this.Offset = offset; |
| | 0 | 30 | | this.SequenceNumber = sequenceNumber; |
| | 0 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Creates a new Checkpoint from an existing checkpoint. |
| | | 35 | | /// </summary> |
| | | 36 | | /// <param name="source">The existing checkpoint to copy</param> |
| | 0 | 37 | | public Checkpoint(Checkpoint source) |
| | | 38 | | { |
| | 0 | 39 | | this.PartitionId = source.PartitionId; |
| | 0 | 40 | | this.Offset = source.Offset; |
| | 0 | 41 | | this.SequenceNumber = source.SequenceNumber; |
| | 0 | 42 | | } |
| | | 43 | | |
| | | 44 | | /// <summary> |
| | | 45 | | /// Gets or sets the offset of the last processed <see cref="EventData"/>. |
| | | 46 | | /// </summary> |
| | 0 | 47 | | public string Offset { get; set; } |
| | | 48 | | |
| | | 49 | | /// <summary> |
| | | 50 | | /// Gets or sets the sequence number of the last processed <see cref="EventData"/>. |
| | | 51 | | /// </summary> |
| | 0 | 52 | | public long SequenceNumber { get; set; } |
| | | 53 | | |
| | | 54 | | /// <summary> |
| | | 55 | | /// Gets the partition ID for the corresponding checkpoint. |
| | | 56 | | /// </summary> |
| | 0 | 57 | | public string PartitionId { get; } |
| | | 58 | | } |
| | | 59 | | } |