Skip to content

Commit

Permalink
[Event Hubs Client] Minor Fixes (Azure#18054)
Browse files Browse the repository at this point in the history
The focus of these changes is to hide previously overlooked members related
to the idempotent publishing feature and to fix an inadvertent breaking change.
  • Loading branch information
jsquire authored and Minnie Liu committed Jan 23, 2021
1 parent f9e376d commit ccd0789
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public EventData(System.ReadOnlyMemory<byte> eventBody) { }
public long Offset { get { throw null; } }
public string PartitionKey { get { throw null; } }
public System.Collections.Generic.IDictionary<string, object> Properties { get { throw null; } }
public int? PublishedSequenceNumber { get { throw null; } }
public long SequenceNumber { get { throw null; } }
public System.Collections.Generic.IReadOnlyDictionary<string, object> SystemProperties { get { throw null; } }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
Expand Down Expand Up @@ -485,7 +484,6 @@ internal EventDataBatch() { }
public int Count { get { throw null; } }
public long MaximumSizeInBytes { get { throw null; } }
public long SizeInBytes { get { throw null; } }
public int? StartingPublishedSequenceNumber { get { throw null; } }
public void Dispose() { }
public bool TryAdd(Azure.Messaging.EventHubs.EventData eventData) { throw null; }
}
Expand Down Expand Up @@ -513,8 +511,8 @@ public EventHubProducerClient(string connectionString, string eventHubName, Azur
public virtual System.Threading.Tasks.Task<string[]> GetPartitionIdsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task<Azure.Messaging.EventHubs.PartitionProperties> GetPartitionPropertiesAsync(string partitionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task SendAsync(Azure.Messaging.EventHubs.Producer.EventDataBatch eventBatch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task SendAsync(System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData> eventSet, Azure.Messaging.EventHubs.Producer.SendEventOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task SendAsync(System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData> eventSet, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task SendAsync(System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData> eventBatch, Azure.Messaging.EventHubs.Producer.SendEventOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual System.Threading.Tasks.Task SendAsync(System.Collections.Generic.IEnumerable<Azure.Messaging.EventHubs.EventData> eventBatch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override string ToString() { throw null; }
}
Expand Down
2 changes: 1 addition & 1 deletion sdk/eventhub/Azure.Messaging.EventHubs/src/EventData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public class EventData
/// of the producer are enabled. For example, it is used by idempotent publishing.
/// </remarks>
///
public int? PublishedSequenceNumber { get; private set; }
internal int? PublishedSequenceNumber { get; private set; }

/// <summary>
/// The sequence number assigned to the event when it was enqueued in the associated Event Hub partition.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public sealed class EventDataBatch : IDisposable
/// of the producer are enabled. For example, it is used by idempotent publishing.
/// </remarks>
///
public int? StartingPublishedSequenceNumber { get; internal set; }
internal int? StartingPublishedSequenceNumber { get; set; } // Setter should be internal when member is made public

/// <summary>
/// The count of events contained in the batch.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ internal virtual async Task SendAsync(EventData eventData,
/// size of a single batch.
/// </summary>
///
/// <param name="eventSet">The set of event data to send.</param>
/// <param name="eventBatch">The set of event data to send.</param>
/// <param name="cancellationToken">An optional <see cref="CancellationToken" /> instance to signal the request to cancel the operation.</param>
///
/// <returns>
Expand All @@ -579,8 +579,8 @@ internal virtual async Task SendAsync(EventData eventData,
/// <seealso cref="SendAsync(EventDataBatch, CancellationToken)" />
/// <seealso cref="CreateBatchAsync(CancellationToken)" />
///
public virtual async Task SendAsync(IEnumerable<EventData> eventSet,
CancellationToken cancellationToken = default) => await SendAsync(eventSet, null, cancellationToken).ConfigureAwait(false);
public virtual async Task SendAsync(IEnumerable<EventData> eventBatch,
CancellationToken cancellationToken = default) => await SendAsync(eventBatch, null, cancellationToken).ConfigureAwait(false);

/// <summary>
/// Sends a set of events to the associated Event Hub as a single operation. To avoid the
Expand All @@ -590,7 +590,7 @@ public virtual async Task SendAsync(IEnumerable<EventData> eventSet,
/// size of a single batch.
/// </summary>
///
/// <param name="eventSet">The set of event data to send.</param>
/// <param name="eventBatch">The set of event data to send.</param>
/// <param name="options">The set of options to consider when sending this batch.</param>
/// <param name="cancellationToken">An optional <see cref="CancellationToken" /> instance to signal the request to cancel the operation.</param>
///
Expand All @@ -613,19 +613,19 @@ public virtual async Task SendAsync(IEnumerable<EventData> eventSet,
/// <seealso cref="SendAsync(EventDataBatch, CancellationToken)" />
/// <seealso cref="CreateBatchAsync(CreateBatchOptions, CancellationToken)" />
///
public virtual async Task SendAsync(IEnumerable<EventData> eventSet,
public virtual async Task SendAsync(IEnumerable<EventData> eventBatch,
SendEventOptions options,
CancellationToken cancellationToken = default)
{
options = options?.Clone() ?? DefaultSendOptions;

Argument.AssertNotNull(eventSet, nameof(eventSet));
Argument.AssertNotNull(eventBatch, nameof(eventBatch));
AssertSinglePartitionReference(options.PartitionId, options.PartitionKey);

var events = eventSet switch
var events = eventBatch switch
{
IReadOnlyList<EventData> eventList => eventList,
_ => eventSet.ToList()
_ => eventBatch.ToList()
};

if (events.Count == 0)
Expand Down

0 comments on commit ccd0789

Please sign in to comment.