Skip to content

Commit 300d42d

Browse files
Bump major (#641)
* Cleanup public API * Bump the major * Remove unneeded attribute * Allow initialization to be cancelled --------- Co-authored-by: danielmarbach <[email protected]>
1 parent 89c4a15 commit 300d42d

File tree

7 files changed

+67
-59
lines changed

7 files changed

+67
-59
lines changed

src/Custom.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<PropertyGroup>
8-
<MinVerMinimumMajorMinor>5.0</MinVerMinimumMajorMinor>
8+
<MinVerMinimumMajorMinor>6.0</MinVerMinimumMajorMinor>
99
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
1010
</PropertyGroup>
1111

src/NServiceBus.AzureFunctions.Worker.ServiceBus.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"NServiceBus.AzureFunctions.Worker.ServiceBus.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")]
22
namespace NServiceBus
33
{
4-
[System.Obsolete("Use `IFunctionEndpoint` instead. Will be treated as an error from version 6.0.0. " +
5-
"Will be removed in version 7.0.0.", false)]
4+
[System.Obsolete("Use `IFunctionEndpoint` instead. Will be removed in version 7.0.0.", true)]
65
public class FunctionEndpoint : NServiceBus.IFunctionEndpoint
76
{
7+
public FunctionEndpoint() { }
88
public System.Threading.Tasks.Task Process(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, Microsoft.Azure.Functions.Worker.ServiceBusMessageActions messageActions, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default) { }
9-
[System.Obsolete(@"Change the function signature to accept a ServiceBusReceivedMessage and the ServiceBusMessageActions instead of binding to individual elements of the ServiceBusReceivedMessage. Use `Process(ServiceBusReceiveMessage message, ServiceBusMessageActions messageActions, FunctionContext functionContext, CancellationToken cancellationToken = default)` instead. Will be removed in version 6.0.0.", true)]
10-
public System.Threading.Tasks.Task Process(byte[] body, System.Collections.Generic.IDictionary<string, object> userProperties, string messageId, int deliveryCount, string replyTo, string correlationId, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default) { }
119
public System.Threading.Tasks.Task Publish(object message, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default) { }
1210
public System.Threading.Tasks.Task Publish(object message, NServiceBus.PublishOptions options, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default) { }
1311
public System.Threading.Tasks.Task Publish<T>(System.Action<T> messageConstructor, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default) { }
@@ -32,8 +30,6 @@ namespace NServiceBus
3230
public interface IFunctionEndpoint
3331
{
3432
System.Threading.Tasks.Task Process(Azure.Messaging.ServiceBus.ServiceBusReceivedMessage message, Microsoft.Azure.Functions.Worker.ServiceBusMessageActions messageActions, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default);
35-
[System.Obsolete(@"Change the function signature to accept a ServiceBusReceivedMessage and the ServiceBusMessageActions instead of binding to individual elements of the ServiceBusReceivedMessage. Use `Process(ServiceBusReceiveMessage message, ServiceBusMessageActions messageActions, FunctionContext functionContext, CancellationToken cancellationToken = default)` instead. Will be removed in version 6.0.0.", true)]
36-
System.Threading.Tasks.Task Process(byte[] body, System.Collections.Generic.IDictionary<string, object> userProperties, string messageId, int deliveryCount, string replyTo, string correlationId, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default);
3733
System.Threading.Tasks.Task Publish(object message, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default);
3834
System.Threading.Tasks.Task Publish(object message, NServiceBus.PublishOptions options, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default);
3935
System.Threading.Tasks.Task Publish<T>(System.Action<T> messageConstructor, Microsoft.Azure.Functions.Worker.FunctionContext functionContext, System.Threading.CancellationToken cancellationToken = default);

src/NServiceBus.AzureFunctions.Worker.ServiceBus/FunctionsHostBuilderExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,12 +149,12 @@ static void RegisterEndpointFactory(
149149
_ = services.AddSingleton(serverlessTransport);
150150

151151
// we are manually resolving all dependencies of FunctionEndpoint since Serverless transport is internal and we run into constructor selection issues if not
152-
_ = services.AddSingleton(sp => new FunctionEndpoint(
152+
_ = services.AddSingleton(sp => new InternalFunctionEndpoint(
153153
sp.GetRequiredService<IStartableEndpointWithExternallyManagedContainer>(),
154154
sp.GetRequiredService<ServerlessTransport>(),
155155
sp));
156156

157-
_ = services.AddSingleton<IFunctionEndpoint>(sp => sp.GetRequiredService<FunctionEndpoint>());
157+
_ = services.AddSingleton<IFunctionEndpoint>(sp => sp.GetRequiredService<InternalFunctionEndpoint>());
158158
return;
159159

160160
string TryResolveBindingExpression()

src/NServiceBus.AzureFunctions.Worker.ServiceBus/IFunctionEndpoint.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
namespace NServiceBus
22
{
33
using System;
4-
using System.Collections.Generic;
5-
using System.Linq;
64
using System.Threading;
75
using System.Threading.Tasks;
86
using Azure.Messaging.ServiceBus;
@@ -17,29 +15,7 @@ public interface IFunctionEndpoint
1715
/// <summary>
1816
/// Processes a message received from an AzureServiceBus trigger using the NServiceBus message pipeline.
1917
/// </summary>
20-
Task Process(
21-
ServiceBusReceivedMessage message,
22-
ServiceBusMessageActions messageActions,
23-
FunctionContext functionContext,
24-
CancellationToken cancellationToken = default) =>
25-
Process(message.Body.ToArray(), message.ApplicationProperties.ToDictionary(),
26-
message.MessageId, message.DeliveryCount,
27-
message.ReplyTo, message.CorrelationId, functionContext,
28-
cancellationToken);
29-
30-
/// <summary>
31-
/// Processes a message received from an AzureServiceBus trigger using the NServiceBus message pipeline.
32-
/// </summary>
33-
[ObsoleteEx(Message = "Change the function signature to accept a ServiceBusReceivedMessage and the ServiceBusMessageActions instead of binding to individual elements of the ServiceBusReceivedMessage.", TreatAsErrorFromVersion = "5.0.0", RemoveInVersion = "6.0.0", ReplacementTypeOrMember = "Process(ServiceBusReceiveMessage message, ServiceBusMessageActions messageActions, FunctionContext functionContext, CancellationToken cancellationToken = default)")]
34-
Task Process(
35-
byte[] body,
36-
IDictionary<string, object> userProperties,
37-
string messageId,
38-
int deliveryCount,
39-
string replyTo,
40-
string correlationId,
41-
FunctionContext functionContext,
42-
CancellationToken cancellationToken = default);
18+
Task Process(ServiceBusReceivedMessage message, ServiceBusMessageActions messageActions, FunctionContext functionContext, CancellationToken cancellationToken = default);
4319

4420
/// <summary>
4521
/// Sends the provided message.

src/NServiceBus.AzureFunctions.Worker.ServiceBus/InitializationHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Threading.Tasks;
55
using Microsoft.Extensions.Hosting;
66

7-
class InitializationHost(FunctionEndpoint functionEndpoint) : IHostedService
7+
class InitializationHost(InternalFunctionEndpoint functionEndpoint) : IHostedService
88
{
99
public Task StartAsync(CancellationToken cancellationToken = default) => functionEndpoint.InitializeEndpointIfNecessary(cancellationToken);
1010

src/NServiceBus.AzureFunctions.Worker.ServiceBus/FunctionEndpoint.cs renamed to src/NServiceBus.AzureFunctions.Worker.ServiceBus/InternalFunctionEndpoint.cs

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
11
namespace NServiceBus
22
{
33
using System;
4-
using System.Collections.Generic;
54
using System.Threading;
65
using System.Threading.Tasks;
76
using Azure.Messaging.ServiceBus;
87
using AzureFunctions.Worker.ServiceBus;
98
using Microsoft.Azure.Functions.Worker;
109

11-
/// <summary>
12-
/// An NServiceBus endpoint hosted in Azure Function which does not receive messages automatically but only handles
13-
/// messages explicitly passed to it by the caller.
14-
/// </summary>
15-
[ObsoleteEx(TreatAsErrorFromVersion = "6", RemoveInVersion = "7", ReplacementTypeOrMember = nameof(IFunctionEndpoint))]
16-
public class FunctionEndpoint : IFunctionEndpoint
10+
sealed class InternalFunctionEndpoint : IFunctionEndpoint
1711
{
18-
internal FunctionEndpoint(IStartableEndpointWithExternallyManagedContainer externallyManagedContainerEndpoint, ServerlessTransport serverlessTransport, IServiceProvider serviceProvider)
12+
internal InternalFunctionEndpoint(IStartableEndpointWithExternallyManagedContainer externallyManagedContainerEndpoint, ServerlessTransport serverlessTransport, IServiceProvider serviceProvider)
1913
{
2014
this.serverlessTransport = serverlessTransport;
2115
this.serverlessTransport.ServiceProvider = serviceProvider;
@@ -28,28 +22,13 @@ public async Task Process(ServiceBusReceivedMessage message, ServiceBusMessageAc
2822
{
2923
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionContext.GetLogger("NServiceBus"));
3024

31-
await InitializeEndpointIfNecessary(CancellationToken.None)
25+
await InitializeEndpointIfNecessary(cancellationToken)
3226
.ConfigureAwait(false);
3327

3428
await messageProcessor.Process(message, messageActions, cancellationToken)
3529
.ConfigureAwait(false);
3630
}
3731

38-
/// <inheritdoc />
39-
[ObsoleteEx(Message = "Change the function signature to accept a ServiceBusReceivedMessage and the ServiceBusMessageActions instead of binding to individual elements of the ServiceBusReceivedMessage.", TreatAsErrorFromVersion = "5.0.0", RemoveInVersion = "6.0.0", ReplacementTypeOrMember = "Process(ServiceBusReceiveMessage message, ServiceBusMessageActions messageActions, FunctionContext functionContext, CancellationToken cancellationToken = default)")]
40-
public Task Process(
41-
byte[] body,
42-
IDictionary<string, object> userProperties,
43-
string messageId,
44-
int deliveryCount,
45-
string replyTo,
46-
string correlationId,
47-
FunctionContext functionContext,
48-
CancellationToken cancellationToken = default) =>
49-
Process(ServiceBusModelFactory.ServiceBusReceivedMessage(BinaryData.FromBytes(body),
50-
properties: userProperties, messageId: messageId, deliveryCount: deliveryCount,
51-
correlationId: correlationId, replyTo: replyTo), default, functionContext, cancellationToken);
52-
5332
internal async Task InitializeEndpointIfNecessary(CancellationToken cancellationToken = default)
5433
{
5534
if (messageProcessor == null)
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
2+
3+
namespace NServiceBus;
4+
5+
using System;
6+
using System.Threading;
7+
using System.Threading.Tasks;
8+
using Azure.Messaging.ServiceBus;
9+
using Microsoft.Azure.Functions.Worker;
10+
11+
[ObsoleteEx(TreatAsErrorFromVersion = "6", RemoveInVersion = "7", ReplacementTypeOrMember = nameof(IFunctionEndpoint))]
12+
public class FunctionEndpoint : IFunctionEndpoint
13+
{
14+
public Task Process(ServiceBusReceivedMessage message, ServiceBusMessageActions messageActions,
15+
FunctionContext functionContext, CancellationToken cancellationToken = default) =>
16+
throw new NotImplementedException();
17+
18+
public Task Send(object message, SendOptions options, FunctionContext functionContext,
19+
CancellationToken cancellationToken = default) =>
20+
throw new NotImplementedException();
21+
22+
public Task Send(object message, FunctionContext functionContext, CancellationToken cancellationToken = default) => throw new NotImplementedException();
23+
24+
public Task Send<T>(Action<T> messageConstructor, SendOptions options, FunctionContext functionContext,
25+
CancellationToken cancellationToken = default) =>
26+
throw new NotImplementedException();
27+
28+
public Task Send<T>(Action<T> messageConstructor, FunctionContext functionContext, CancellationToken cancellationToken = default) => throw new NotImplementedException();
29+
30+
public Task Publish(object message, PublishOptions options, FunctionContext functionContext,
31+
CancellationToken cancellationToken = default) =>
32+
throw new NotImplementedException();
33+
34+
public Task Publish<T>(Action<T> messageConstructor, PublishOptions options, FunctionContext functionContext,
35+
CancellationToken cancellationToken = default) =>
36+
throw new NotImplementedException();
37+
38+
public Task Publish(object message, FunctionContext functionContext, CancellationToken cancellationToken = default) => throw new NotImplementedException();
39+
40+
public Task Publish<T>(Action<T> messageConstructor, FunctionContext functionContext,
41+
CancellationToken cancellationToken = default) =>
42+
throw new NotImplementedException();
43+
44+
public Task Subscribe(Type eventType, SubscribeOptions options, FunctionContext functionContext,
45+
CancellationToken cancellationToken = default) =>
46+
throw new NotImplementedException();
47+
48+
public Task Subscribe(Type eventType, FunctionContext functionContext, CancellationToken cancellationToken = default) => throw new NotImplementedException();
49+
50+
public Task Unsubscribe(Type eventType, UnsubscribeOptions options, FunctionContext functionContext,
51+
CancellationToken cancellationToken = default) =>
52+
throw new NotImplementedException();
53+
54+
public Task Unsubscribe(Type eventType, FunctionContext functionContext, CancellationToken cancellationToken = default) => throw new NotImplementedException();
55+
}
56+
57+
#pragma warning restore CS1591 // Missing XML comment for publicly visible type or member

0 commit comments

Comments
 (0)