| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using Azure.Core; |
| | 5 | |
|
| | 6 | | namespace Azure.Messaging.EventHubs.Consumer |
| | 7 | | { |
| | 8 | | /// <summary> |
| | 9 | | /// Contains information about a partition that has attempted to receive an event from the Azure Event Hub |
| | 10 | | /// service, as well as the received event, if any. |
| | 11 | | /// </summary> |
| | 12 | | /// |
| | 13 | | public struct PartitionEvent |
| | 14 | | { |
| | 15 | | /// <summary> |
| | 16 | | /// The Event Hub partition that the <see cref="PartitionEvent.Data" /> is associated with. |
| | 17 | | /// </summary> |
| | 18 | | /// |
| 5800 | 19 | | public PartitionContext Partition { get; } |
| | 20 | |
|
| | 21 | | /// <summary> |
| | 22 | | /// An event that was read from the associated <see cref="PartitionEvent.Partition" />. |
| | 23 | | /// </summary> |
| | 24 | | /// |
| | 25 | | /// <value> |
| | 26 | | /// The <see cref="EventData" /> read from the Event Hub partition, if data was available. |
| | 27 | | /// If a maximum wait time was specified when reading events and no event was available in that |
| | 28 | | /// time period, <c>null</c>. |
| | 29 | | /// </value> |
| | 30 | | /// |
| | 31 | | /// <remarks> |
| | 32 | | /// Ownership of this data, including the memory that holds its <see cref="EventData.Body" />, |
| | 33 | | /// is assumed to transfer to consumers of the <see cref="PartitionEvent" />. It may be considered |
| | 34 | | /// immutable and is safe to access so long as the reference is held. |
| | 35 | | /// </remarks> |
| | 36 | | /// |
| 7602 | 37 | | public EventData Data { get; } |
| | 38 | |
|
| | 39 | | /// <summary> |
| | 40 | | /// Initializes a new instance of the <see cref="PartitionEvent"/> structure. |
| | 41 | | /// </summary> |
| | 42 | | /// |
| | 43 | | /// <param name="partition">The Event Hub partition that the <paramref name="data" /> is associated with.</param |
| | 44 | | /// <param name="data">The event that was read, if events were available; otherwise, <c>null</c>.</param> |
| | 45 | | /// |
| | 46 | | public PartitionEvent(PartitionContext partition, |
| | 47 | | EventData data) |
| | 48 | | { |
| 9450 | 49 | | Argument.AssertNotNull(partition, nameof(partition)); |
| | 50 | |
|
| 9450 | 51 | | Partition = partition; |
| 9450 | 52 | | Data = data; |
| 9450 | 53 | | } |
| | 54 | | } |
| | 55 | | } |