Skip to content

Commit 624d630

Browse files
authored
Remove more properties from EventHubOptions (Azure#19140)
1 parent b5c7a1b commit 624d630

File tree

10 files changed

+34
-96
lines changed

10 files changed

+34
-96
lines changed

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/api/Microsoft.Azure.WebJobs.Extensions.EventHubs.netstandard2.0.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,17 @@ public partial class EventHubOptions : Microsoft.Azure.WebJobs.Hosting.IOptionsF
2424
{
2525
public EventHubOptions() { }
2626
public int BatchCheckpointFrequency { get { throw null; } set { } }
27+
public Azure.Messaging.EventHubs.EventHubsRetryOptions ClientRetryOptions { get { throw null; } set { } }
2728
public Azure.Messaging.EventHubs.EventHubConnectionOptions ConnectionOptions { get { throw null; } set { } }
2829
public Microsoft.Azure.WebJobs.EventHubs.InitialOffsetOptions InitialOffsetOptions { get { throw null; } }
29-
public bool InvokeFunctionAfterReceiveTimeout { get { throw null; } set { } }
3030
public System.TimeSpan LoadBalancingUpdateInterval { get { throw null; } set { } }
3131
public int MaxBatchSize { get { throw null; } set { } }
32-
public System.TimeSpan MaximumWaitTime { get { throw null; } set { } }
3332
public System.TimeSpan PartitionOwnershipExpirationInterval { get { throw null; } set { } }
3433
public int PrefetchCount { get { throw null; } set { } }
3534
public long? PrefetchSizeInBytes { get { throw null; } set { } }
36-
public Azure.Messaging.EventHubs.EventHubsRetryOptions RetryOptions { get { throw null; } set { } }
3735
public bool TrackLastEnqueuedEventProperties { get { throw null; } set { } }
3836
string Microsoft.Azure.WebJobs.Hosting.IOptionsFormatter.Format() { throw null; }
3937
}
40-
public partial class EventHubsWebJobsStartup : Microsoft.Azure.WebJobs.Hosting.IWebJobsStartup
41-
{
42-
public EventHubsWebJobsStartup() { }
43-
public void Configure(Microsoft.Azure.WebJobs.IWebJobsBuilder builder) { }
44-
}
4538
public partial class InitialOffsetOptions
4639
{
4740
public InitialOffsetOptions() { }

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Config/EventHubClientFactory.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ internal EventHubProducerClient GetEventHubProducerClient(string eventHubName, s
5858
info.TokenCredential,
5959
new EventHubProducerClientOptions
6060
{
61-
RetryOptions = _options.RetryOptions,
61+
RetryOptions = _options.ClientRetryOptions,
6262
ConnectionOptions = _options.ConnectionOptions
6363
});
6464
}
@@ -67,7 +67,7 @@ internal EventHubProducerClient GetEventHubProducerClient(string eventHubName, s
6767
NormalizeConnectionString(info.ConnectionString, eventHubName),
6868
new EventHubProducerClientOptions
6969
{
70-
RetryOptions = _options.RetryOptions,
70+
RetryOptions = _options.ClientRetryOptions,
7171
ConnectionOptions = _options.ConnectionOptions
7272
});
7373
}
@@ -97,7 +97,6 @@ internal EventProcessorHost GetEventProcessorHost(string eventHubName, string co
9797
credential: info.TokenCredential,
9898
options: _options.EventProcessorOptions,
9999
eventBatchMaximumCount: _options.MaxBatchSize,
100-
invokeProcessorAfterReceiveTimeout: _options.InvokeFunctionAfterReceiveTimeout,
101100
exceptionHandler: _options.ExceptionHandler);
102101
}
103102

@@ -106,7 +105,6 @@ internal EventProcessorHost GetEventProcessorHost(string eventHubName, string co
106105
eventHubName: eventHubName,
107106
options: _options.EventProcessorOptions,
108107
eventBatchMaximumCount: _options.MaxBatchSize,
109-
invokeProcessorAfterReceiveTimeout: _options.InvokeFunctionAfterReceiveTimeout,
110108
exceptionHandler: _options.ExceptionHandler);
111109
}
112110

@@ -138,7 +136,7 @@ internal IEventHubConsumerClient GetEventHubConsumerClient(string eventHubName,
138136
info.TokenCredential,
139137
new EventHubConsumerClientOptions
140138
{
141-
RetryOptions = _options.RetryOptions,
139+
RetryOptions = _options.ClientRetryOptions,
142140
ConnectionOptions = _options.ConnectionOptions
143141
});
144142
}
@@ -149,7 +147,7 @@ internal IEventHubConsumerClient GetEventHubConsumerClient(string eventHubName,
149147
NormalizeConnectionString(info.ConnectionString, eventHubName),
150148
new EventHubConsumerClientOptions
151149
{
152-
RetryOptions = _options.RetryOptions,
150+
RetryOptions = _options.ClientRetryOptions,
153151
ConnectionOptions = _options.ConnectionOptions
154152
});
155153
}

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Config/EventHubOptions.cs

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
// Licensed under the MIT License. See License.txt in the project root for license information.
33

44
using System;
5-
using System.Collections.Generic;
6-
using System.Globalization;
7-
using System.Text;
85
using Azure.Messaging.EventHubs;
96
using Azure.Messaging.EventHubs.Consumer;
107
using Azure.Messaging.EventHubs.Primitives;
11-
using Azure.Messaging.EventHubs.Processor;
12-
using Azure.Messaging.EventHubs.Producer;
138
using Microsoft.Azure.WebJobs.EventHubs.Processor;
149
using Microsoft.Azure.WebJobs.Hosting;
1510
using Newtonsoft.Json;
@@ -22,7 +17,6 @@ public class EventHubOptions : IOptionsFormatter
2217
public EventHubOptions()
2318
{
2419
MaxBatchSize = 10;
25-
InvokeFunctionAfterReceiveTimeout = false;
2620
EventProcessorOptions = new EventProcessorOptions()
2721
{
2822
TrackLastEnqueuedEventProperties = false,
@@ -51,7 +45,7 @@ public EventHubConnectionOptions ConnectionOptions
5145
/// amount of time allowed for receiving event batches and other interactions with the Event Hubs service.
5246
/// </summary>
5347
///
54-
public EventHubsRetryOptions RetryOptions
48+
public EventHubsRetryOptions ClientRetryOptions
5549
{
5650
get => EventProcessorOptions.RetryOptions;
5751
set => EventProcessorOptions.RetryOptions = value;
@@ -95,11 +89,6 @@ public int MaxBatchSize
9589
}
9690
}
9791

98-
/// <summary>
99-
/// Returns whether the function would be triggered when a receive timeout occurs.
100-
/// </summary>
101-
public bool InvokeFunctionAfterReceiveTimeout { get; set; }
102-
10392
/// <summary>
10493
/// Gets the initial offset options to apply when processing. This only applies
10594
/// when no checkpoint information is available.
@@ -127,16 +116,6 @@ public long? PrefetchSizeInBytes
127116
set => EventProcessorOptions.PrefetchSizeInBytes = value;
128117
}
129118

130-
/// <summary>
131-
/// The maximum amount of time to wait for events to become available. If <see cref="InvokeFunctionAfterReceiveTimeout"/> is true,
132-
/// the function will be triggered with an empty <see cref="EventData"/>.
133-
/// </summary>
134-
public TimeSpan MaximumWaitTime
135-
{
136-
get => EventProcessorOptions.MaximumWaitTime.Value;
137-
set => EventProcessorOptions.MaximumWaitTime = value;
138-
}
139-
140119
/// <inheritdoc cref="EventProcessorOptions.PartitionOwnershipExpirationInterval"/>
141120
public TimeSpan PartitionOwnershipExpirationInterval
142121
{
@@ -163,14 +142,12 @@ string IOptionsFormatter.Format()
163142
JObject options = new JObject
164143
{
165144
{ nameof(MaxBatchSize), MaxBatchSize },
166-
{ nameof(InvokeFunctionAfterReceiveTimeout), InvokeFunctionAfterReceiveTimeout },
167145
{ nameof(BatchCheckpointFrequency), BatchCheckpointFrequency },
168146
{ nameof(ConnectionOptions), ConstructConnectionOptions() },
169-
{ nameof(RetryOptions), ConstructRetryOptions() },
147+
{ nameof(ClientRetryOptions), ConstructRetryOptions() },
170148
{ nameof(TrackLastEnqueuedEventProperties), TrackLastEnqueuedEventProperties },
171149
{ nameof(PrefetchCount), PrefetchCount },
172150
{ nameof(PrefetchSizeInBytes), PrefetchSizeInBytes },
173-
{ nameof(MaximumWaitTime), MaximumWaitTime },
174151
{ nameof(PartitionOwnershipExpirationInterval), PartitionOwnershipExpirationInterval },
175152
{ nameof(LoadBalancingUpdateInterval), LoadBalancingUpdateInterval },
176153
{ nameof(InitialOffsetOptions), ConstructInitialOffsetOptions() },
@@ -188,11 +165,11 @@ private JObject ConstructConnectionOptions() =>
188165
private JObject ConstructRetryOptions() =>
189166
new JObject
190167
{
191-
{ nameof(EventHubsRetryOptions.Mode), RetryOptions.Mode.ToString() },
192-
{ nameof(EventHubsRetryOptions.TryTimeout), RetryOptions.TryTimeout },
193-
{ nameof(EventHubsRetryOptions.Delay), RetryOptions.Delay },
194-
{ nameof(EventHubsRetryOptions.MaximumDelay), RetryOptions.MaximumDelay },
195-
{ nameof(EventHubsRetryOptions.MaximumRetries), RetryOptions.MaximumRetries },
168+
{ nameof(EventHubsRetryOptions.Mode), ClientRetryOptions.Mode.ToString() },
169+
{ nameof(EventHubsRetryOptions.TryTimeout), ClientRetryOptions.TryTimeout },
170+
{ nameof(EventHubsRetryOptions.Delay), ClientRetryOptions.Delay },
171+
{ nameof(EventHubsRetryOptions.MaximumDelay), ClientRetryOptions.MaximumDelay },
172+
{ nameof(EventHubsRetryOptions.MaximumRetries), ClientRetryOptions.MaximumRetries },
196173
};
197174

198175
private JObject ConstructInitialOffsetOptions() =>

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Config/EventHubWebJobsBuilderExtensions.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,6 @@ public static IWebJobsBuilder AddEventHubs(this IWebJobsBuilder builder, Action<
4242
{
4343
// Map old property names for backwards compatibility
4444
// do it before the binding so new property names take precedence
45-
options.InvokeFunctionAfterReceiveTimeout = section.GetValue(
46-
"EventProcessorOptions:InvokeProcessorAfterReceiveTimeout",
47-
options.InvokeFunctionAfterReceiveTimeout);
48-
4945
options.TrackLastEnqueuedEventProperties = section.GetValue(
5046
"EventProcessorOptions:EnableReceiverRuntimeMetric",
5147
options.TrackLastEnqueuedEventProperties);
@@ -58,15 +54,6 @@ public static IWebJobsBuilder AddEventHubs(this IWebJobsBuilder builder, Action<
5854
"EventProcessorOptions:PrefetchCount",
5955
options.PrefetchCount);
6056

61-
var receiveTimeout = section.GetValue<TimeSpan?>(
62-
"EventProcessorOptions:ReceiveTimeout",
63-
null);
64-
65-
if (receiveTimeout != null)
66-
{
67-
options.MaximumWaitTime = receiveTimeout.Value;
68-
}
69-
7057
var leaseDuration = section.GetValue<TimeSpan?>(
7158
"PartitionManagerOptions:LeaseDuration",
7259
null);

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/EventHubsWebJobsStartup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
namespace Microsoft.Azure.WebJobs.EventHubs
1111
{
12-
public class EventHubsWebJobsStartup : IWebJobsStartup
12+
internal class EventHubsWebJobsStartup : IWebJobsStartup
1313
{
1414
public void Configure(IWebJobsBuilder builder)
1515
{

sdk/eventhub/Microsoft.Azure.WebJobs.Extensions.EventHubs/src/Processor/EventProcessorHost.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ namespace Microsoft.Azure.WebJobs.EventHubs.Processor
1515
{
1616
internal class EventProcessorHost : EventProcessor<EventProcessorHostPartition>
1717
{
18-
private readonly bool _invokeProcessorAfterReceiveTimeout;
1918
private readonly Action<ExceptionReceivedEventArgs> _exceptionHandler;
2019
private IEventProcessorFactory _processorFactory;
2120
private BlobsCheckpointStore _checkpointStore;
@@ -32,10 +31,8 @@ public EventProcessorHost(string consumerGroup,
3231
string eventHubName,
3332
EventProcessorOptions options,
3433
int eventBatchMaximumCount,
35-
bool invokeProcessorAfterReceiveTimeout,
3634
Action<ExceptionReceivedEventArgs> exceptionHandler) : base(eventBatchMaximumCount, consumerGroup, connectionString, eventHubName, options)
3735
{
38-
_invokeProcessorAfterReceiveTimeout = invokeProcessorAfterReceiveTimeout;
3936
_exceptionHandler = exceptionHandler;
4037
}
4138

@@ -45,10 +42,8 @@ public EventProcessorHost(string consumerGroup,
4542
string eventHubName,
4643
EventProcessorOptions options,
4744
int eventBatchMaximumCount,
48-
bool invokeProcessorAfterReceiveTimeout,
4945
Action<ExceptionReceivedEventArgs> exceptionHandler) : base(eventBatchMaximumCount, consumerGroup, fullyQualifiedNamespace, eventHubName, credential, options)
5046
{
51-
_invokeProcessorAfterReceiveTimeout = invokeProcessorAfterReceiveTimeout;
5247
_exceptionHandler = exceptionHandler;
5348
}
5449

@@ -104,7 +99,7 @@ protected override Task OnProcessingErrorAsync(Exception exception, EventProcess
10499

105100
protected override Task OnProcessingEventBatchAsync(IEnumerable<EventData> events, EventProcessorHostPartition partition, CancellationToken cancellationToken)
106101
{
107-
if ((events == null || !events.Any()) && !_invokeProcessorAfterReceiveTimeout)
102+
if (events == null || !events.Any())
108103
{
109104
return Task.CompletedTask;
110105
}

0 commit comments

Comments
 (0)