Skip to content

Commit d88d187

Browse files
authored
[Event Hubs Client] Internalize Idempotent Publishing (Azure#18016)
The focus of these changes is to internalize types and members related to the idemtpotent publishing feature, as this will not be included in the next Event Hubs release. A correction was also made to the initial value of the last published sequence number in the `PartitionPublishingProperties` to align with service semantics.
1 parent 5e548be commit d88d187

File tree

7 files changed

+18
-47
lines changed

7 files changed

+18
-47
lines changed

sdk/eventhub/Azure.Messaging.EventHubs/api/Azure.Messaging.EventHubs.netstandard2.0.cs

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public static partial class EventHubsModelFactory
125125
public static Azure.Messaging.EventHubs.Consumer.LastEnqueuedEventProperties LastEnqueuedEventProperties(long? lastSequenceNumber, long? lastOffset, System.DateTimeOffset? lastEnqueuedTime, System.DateTimeOffset? lastReceivedTime) { throw null; }
126126
public static Azure.Messaging.EventHubs.Consumer.PartitionContext PartitionContext(string partitionId, Azure.Messaging.EventHubs.Consumer.LastEnqueuedEventProperties lastEnqueuedEventProperties = default(Azure.Messaging.EventHubs.Consumer.LastEnqueuedEventProperties)) { throw null; }
127127
public static Azure.Messaging.EventHubs.PartitionProperties PartitionProperties(string eventHubName, string partitionId, bool isEmpty, long beginningSequenceNumber, long lastSequenceNumber, long lastOffset, System.DateTimeOffset lastEnqueuedTime) { throw null; }
128-
public static Azure.Messaging.EventHubs.Producer.PartitionPublishingProperties PartitionPublishingProperties(bool isIdempotentPublishingEnabled, long? producerGroupId, short? ownerLevel, int? lastPublishedSequenceNumber) { throw null; }
129128
}
130129
public enum EventHubsRetryMode
131130
{
@@ -512,7 +511,6 @@ public EventHubProducerClient(string connectionString, string eventHubName, Azur
512511
public override int GetHashCode() { throw null; }
513512
public virtual System.Threading.Tasks.Task<string[]> GetPartitionIdsAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
514513
public virtual System.Threading.Tasks.Task<Azure.Messaging.EventHubs.PartitionProperties> GetPartitionPropertiesAsync(string partitionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
515-
public virtual System.Threading.Tasks.Task<Azure.Messaging.EventHubs.Producer.PartitionPublishingProperties> GetPartitionPublishingPropertiesAsync(string partitionId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
516514
public virtual System.Threading.Tasks.Task SendAsync(Azure.Messaging.EventHubs.Producer.EventDataBatch eventBatch, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
517515
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; }
518516
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; }
@@ -523,8 +521,6 @@ public partial class EventHubProducerClientOptions
523521
{
524522
public EventHubProducerClientOptions() { }
525523
public Azure.Messaging.EventHubs.EventHubConnectionOptions ConnectionOptions { get { throw null; } set { } }
526-
public bool EnableIdempotentPartitions { get { throw null; } set { } }
527-
public System.Collections.Generic.Dictionary<string, Azure.Messaging.EventHubs.Producer.PartitionPublishingOptions> PartitionOptions { get { throw null; } }
528524
public Azure.Messaging.EventHubs.EventHubsRetryOptions RetryOptions { get { throw null; } set { } }
529525
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
530526
public override bool Equals(object obj) { throw null; }
@@ -533,33 +529,6 @@ public EventHubProducerClientOptions() { }
533529
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
534530
public override string ToString() { throw null; }
535531
}
536-
public partial class PartitionPublishingOptions
537-
{
538-
public PartitionPublishingOptions() { }
539-
public short? OwnerLevel { get { throw null; } set { } }
540-
public long? ProducerGroupId { get { throw null; } set { } }
541-
public int? StartingSequenceNumber { get { throw null; } set { } }
542-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
543-
public override bool Equals(object obj) { throw null; }
544-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
545-
public override int GetHashCode() { throw null; }
546-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
547-
public override string ToString() { throw null; }
548-
}
549-
public partial class PartitionPublishingProperties
550-
{
551-
protected internal PartitionPublishingProperties(bool isIdempotentPublishingEnabled, long? producerGroupId, short? ownerLevel, int? lastPublishedSequenceNumber) { }
552-
public bool IsIdempotentPublishingEnabled { get { throw null; } }
553-
public int? LastPublishedSequenceNumber { get { throw null; } }
554-
public short? OwnerLevel { get { throw null; } }
555-
public long? ProducerGroupId { get { throw null; } }
556-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
557-
public override bool Equals(object obj) { throw null; }
558-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
559-
public override int GetHashCode() { throw null; }
560-
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
561-
public override string ToString() { throw null; }
562-
}
563532
public partial class SendEventOptions
564533
{
565534
public SendEventOptions() { }

sdk/eventhub/Azure.Messaging.EventHubs/src/EventHubsModelFactory.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ public static PartitionProperties PartitionProperties(string eventHubName,
5959
/// <param name="ownerLevel">The owner level associated with the partition.</param>
6060
/// <param name="lastPublishedSequenceNumber">The sequence number assigned to the event that was last successfully published to the partition.</param>
6161
///
62-
public static PartitionPublishingProperties PartitionPublishingProperties(bool isIdempotentPublishingEnabled,
63-
long? producerGroupId,
64-
short? ownerLevel,
65-
int? lastPublishedSequenceNumber) =>
62+
internal static PartitionPublishingProperties PartitionPublishingProperties(bool isIdempotentPublishingEnabled,
63+
long? producerGroupId,
64+
short? ownerLevel,
65+
int? lastPublishedSequenceNumber) =>
6666
new PartitionPublishingProperties(isIdempotentPublishingEnabled, producerGroupId, ownerLevel, lastPublishedSequenceNumber);
6767

6868
/// <summary>

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,8 +454,8 @@ public virtual async Task<PartitionProperties> GetPartitionPropertiesAsync(strin
454454
/// partition; calling this method for a partition before events have been published to it will return an empty set of properties.
455455
/// </remarks>
456456
///
457-
public virtual async Task<PartitionPublishingProperties> GetPartitionPublishingPropertiesAsync(string partitionId,
458-
CancellationToken cancellationToken = default)
457+
internal virtual async Task<PartitionPublishingProperties> GetPartitionPublishingPropertiesAsync(string partitionId,
458+
CancellationToken cancellationToken = default)
459459
{
460460
Argument.AssertNotClosed(IsClosed, nameof(EventHubProducerClient));
461461
Argument.AssertNotNullOrEmpty(partitionId, nameof(partitionId));

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/EventHubProducerClientOptions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public class EventHubProducerClientOptions
2929
///
3030
/// <value><c>true</c> if the producer should enable idempotent partition publishing; otherwise, <c>false</c>.</value>
3131
///
32-
public bool EnableIdempotentPartitions { get; set; }
32+
internal bool EnableIdempotentPartitions { get; set; }
3333

3434
/// <summary>
3535
/// The set of options that can be specified to influence publishing behavior specific to the configured Event Hub partition. These
@@ -44,7 +44,7 @@ public class EventHubProducerClientOptions
4444
/// These options are ignored when publishing to the Event Hubs gateway for automatic routing or when using a partition key.
4545
/// </remarks>
4646
///
47-
public Dictionary<string, PartitionPublishingOptions> PartitionOptions { get; } = new Dictionary<string, PartitionPublishingOptions>();
47+
internal Dictionary<string, PartitionPublishingOptions> PartitionOptions { get; } = new Dictionary<string, PartitionPublishingOptions>();
4848

4949
/// <summary>
5050
/// The options used for configuring the connection to the Event Hubs service.

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/PartitionPublishingOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace Azure.Messaging.EventHubs.Producer
1515
/// routing or when using a partition key.
1616
/// </remarks>
1717
///
18-
public class PartitionPublishingOptions
18+
internal class PartitionPublishingOptions
1919
{
2020
/// <summary>
2121
/// The identifier of the producer group that this producer is associated with when publishing to the associated partition.

sdk/eventhub/Azure.Messaging.EventHubs/src/Producer/PartitionPublishingProperties.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace Azure.Messaging.EventHubs.Producer
99
/// A set of information for an Event Hub.
1010
/// </summary>
1111
///
12-
public class PartitionPublishingProperties
12+
internal class PartitionPublishingProperties
1313
{
1414
/// <summary>An empty set of properties.</summary>
1515
private static PartitionPublishingProperties s_emptyInstance;
@@ -58,12 +58,14 @@ internal static PartitionPublishingProperties Empty
5858
/// </summary>
5959
///
6060
/// <value>
61-
/// The sequence number will be in the range of <c>0</c> - <see cref="int.MaxValue"/> (inclusive) and will
62-
/// increase as events are published. When more than <see cref="int.MaxValue" /> events have been published,
63-
/// the sequence number will roll over to <c>0</c>.
61+
/// <para>The sequence number will be in the range of <c>-1</c> - <see cref="int.MaxValue"/> (inclusive) and will
62+
/// increase as events are published. When more than <see cref="int.MaxValue" /> events have been published,
63+
/// the sequence number will roll over to <c>0</c>.</para>
64+
///
65+
/// <para>A value of <c>-1</c> indicates that no events are known to have been published.</para>
6466
/// </value>
6567
///
66-
public int? LastPublishedSequenceNumber { get; }
68+
public int? LastPublishedSequenceNumber { get; } = -1;
6769

6870
/// <summary>
6971
/// Determines whether the specified <see cref="System.Object" /> is equal to this instance.

sdk/eventhub/Azure.Messaging.EventHubs/tests/Amqp/AmqpConnectionScopeTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,7 +1205,7 @@ public async Task OpenProducerLinkAsyncConfiguresTheLinkWhenOptionsAreEmpty()
12051205
///
12061206
[Test]
12071207
[TestCaseSource(nameof(PartitionPublishingPartialOptionsTestCases))]
1208-
public async Task OpenProducerLinkAsyncConfiguresTheLinkWhenOptionsAreEmpty(PartitionPublishingOptions options)
1208+
public async Task OpenProducerLinkAsyncConfiguresTheLinkWhenOptionsAreEmpty(object options)
12091209
{
12101210
var endpoint = new Uri("amqp://test.service.gov");
12111211
var eventHub = "myHub";
@@ -1253,7 +1253,7 @@ public async Task OpenProducerLinkAsyncConfiguresTheLinkWhenOptionsAreEmpty(Part
12531253
ItExpr.IsAny<TimeSpan>())
12541254
.Returns(Task.CompletedTask);
12551255

1256-
var link = await mockScope.Object.OpenProducerLinkAsync(partitionId, features, options, TimeSpan.FromDays(1), cancellationSource.Token);
1256+
var link = await mockScope.Object.OpenProducerLinkAsync(partitionId, features, (PartitionPublishingOptions)options, TimeSpan.FromDays(1), cancellationSource.Token);
12571257
Assert.That(link, Is.Not.Null, "The link produced was null");
12581258

12591259
var linkTarget = (Target)link.Settings.Target;

0 commit comments

Comments
 (0)