| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System.ComponentModel; |
| | 5 | | using Azure.Core; |
| | 6 | |
|
| | 7 | | namespace Azure.Messaging.EventHubs.Producer |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// The set of options that can be specified to influence the way in which an event batch |
| | 11 | | /// behaves and is sent to the Event Hubs service. |
| | 12 | | /// </summary> |
| | 13 | | /// |
| | 14 | | public class CreateBatchOptions : SendEventOptions |
| | 15 | | { |
| | 16 | | /// <summary>The requested maximum size to allow for the batch, in bytes.</summary> |
| | 17 | | private long? _maximumSizeInBytes = null; |
| | 18 | |
|
| | 19 | | /// <summary> |
| | 20 | | /// The maximum size to allow for a single batch of events, in bytes. |
| | 21 | | /// </summary> |
| | 22 | | /// |
| | 23 | | /// <value> |
| | 24 | | /// The desired limit, in bytes, for the size of the associated event batch. If <c>null</c>, |
| | 25 | | /// the maximum size allowed by the active transport will be used. |
| | 26 | | /// </value> |
| | 27 | | /// |
| | 28 | | public long? MaximumSizeInBytes |
| | 29 | | { |
| 196 | 30 | | get => _maximumSizeInBytes; |
| | 31 | |
|
| | 32 | | set |
| | 33 | | { |
| 80 | 34 | | if (value.HasValue) |
| | 35 | | { |
| 70 | 36 | | Argument.AssertAtLeast(value.Value, EventHubProducerClient.MinimumBatchSizeLimit, nameof(MaximumSize |
| | 37 | | } |
| | 38 | |
|
| 78 | 39 | | _maximumSizeInBytes = value; |
| 78 | 40 | | } |
| | 41 | | } |
| | 42 | |
|
| | 43 | | /// <summary> |
| | 44 | | /// Creates a new copy of the current <see cref="CreateBatchOptions" />, cloning its attributes into a new ins |
| | 45 | | /// </summary> |
| | 46 | | /// |
| | 47 | | /// <returns>A new copy of <see cref="CreateBatchOptions" />.</returns> |
| | 48 | | /// |
| | 49 | | internal CreateBatchOptions Clone() => |
| 8 | 50 | | new CreateBatchOptions |
| 8 | 51 | | { |
| 8 | 52 | | PartitionId = PartitionId, |
| 8 | 53 | | PartitionKey = PartitionKey, |
| 8 | 54 | | _maximumSizeInBytes = MaximumSizeInBytes |
| 8 | 55 | | }; |
| | 56 | |
|
| | 57 | | /// <summary> |
| | 58 | | /// Determines whether the specified <see cref="System.Object" /> is equal to this instance. |
| | 59 | | /// </summary> |
| | 60 | | /// |
| | 61 | | /// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param> |
| | 62 | | /// |
| | 63 | | /// <returns><c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c> |
| | 64 | | /// |
| | 65 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 66 | | public override bool Equals(object obj) => base.Equals(obj); |
| | 67 | |
|
| | 68 | | /// <summary> |
| | 69 | | /// Returns a hash code for this instance. |
| | 70 | | /// </summary> |
| | 71 | | /// |
| | 72 | | /// <returns>A hash code for this instance, suitable for use in hashing algorithms and data structures like a ha |
| | 73 | | /// |
| | 74 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 75 | | public override int GetHashCode() => base.GetHashCode(); |
| | 76 | |
|
| | 77 | | /// <summary> |
| | 78 | | /// Converts the instance to string representation. |
| | 79 | | /// </summary> |
| | 80 | | /// |
| | 81 | | /// <returns>A <see cref="System.String" /> that represents this instance.</returns> |
| | 82 | | /// |
| | 83 | | [EditorBrowsable(EditorBrowsableState.Never)] |
| 0 | 84 | | public override string ToString() => base.ToString(); |
| | 85 | | } |
| | 86 | | } |