Skip to content

Commit 7ff5e43

Browse files
committed
Remove unused executionContext
1 parent cb1ee00 commit 7ff5e43

4 files changed

Lines changed: 13 additions & 50 deletions

File tree

src/NServiceBus.AzureFunctions.InProcess.ServiceBus/FunctionExecutionContext.cs

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/NServiceBus.AzureFunctions.InProcess.ServiceBus/InProcessFunctionEndpoint.cs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public InProcessFunctionEndpoint(
2222
IServiceProvider serviceProvider)
2323
{
2424
this.serverlessInterceptor = serverlessInterceptor;
25-
endpointFactory = _ => externallyManagedContainerEndpoint.Start(serviceProvider);
25+
endpointFactory = () => externallyManagedContainerEndpoint.Start(serviceProvider);
2626
}
2727

2828
public async Task Send(object message, SendOptions options, ExecutionContext executionContext, ILogger functionsLogger = null, CancellationToken cancellationToken = default)
2929
{
3030
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
3131

32-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
32+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
3333
await endpoint.Send(message, options, cancellationToken).ConfigureAwait(false);
3434
}
3535

@@ -42,7 +42,7 @@ public async Task Send<T>(Action<T> messageConstructor, SendOptions options, Exe
4242
{
4343
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
4444

45-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
45+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
4646
await endpoint.Send(messageConstructor, options, cancellationToken).ConfigureAwait(false);
4747
}
4848

@@ -55,7 +55,7 @@ public async Task Publish(object message, PublishOptions options, ExecutionConte
5555
{
5656
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
5757

58-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
58+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
5959
await endpoint.Publish(message, options, cancellationToken).ConfigureAwait(false);
6060
}
6161

@@ -68,7 +68,7 @@ public async Task Publish<T>(Action<T> messageConstructor, PublishOptions option
6868
{
6969
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
7070

71-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
71+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
7272
await endpoint.Publish(messageConstructor, options, cancellationToken).ConfigureAwait(false);
7373
}
7474

@@ -81,7 +81,7 @@ public async Task Subscribe(Type eventType, SubscribeOptions options, ExecutionC
8181
{
8282
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
8383

84-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
84+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
8585
await endpoint.Subscribe(eventType, options, cancellationToken).ConfigureAwait(false);
8686
}
8787

@@ -94,7 +94,7 @@ public async Task Unsubscribe(Type eventType, UnsubscribeOptions options, Execut
9494
{
9595
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
9696

97-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
97+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
9898
await endpoint.Unsubscribe(eventType, options, cancellationToken).ConfigureAwait(false);
9999
}
100100

@@ -111,7 +111,7 @@ public async Task ProcessNonAtomic(
111111
{
112112
FunctionsLoggerFactory.Instance.SetCurrentLogger(functionsLogger);
113113

114-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken)
114+
await InitializeEndpointIfNecessary(cancellationToken)
115115
.ConfigureAwait(false);
116116

117117
try
@@ -147,7 +147,7 @@ public async Task ProcessAtomic(
147147

148148
try
149149
{
150-
await InitializeEndpointIfNecessary(executionContext, functionsLogger, cancellationToken).ConfigureAwait(false);
150+
await InitializeEndpointIfNecessary(cancellationToken).ConfigureAwait(false);
151151
}
152152
catch (Exception)
153153
{
@@ -251,7 +251,7 @@ static AzureServiceBusTransportTransaction CreateTransaction(string messageParti
251251
"Azure.Security.KeyVault.Secrets.dll"
252252
};
253253

254-
internal async Task InitializeEndpointIfNecessary(ExecutionContext executionContext, ILogger logger, CancellationToken cancellationToken)
254+
internal async Task InitializeEndpointIfNecessary(CancellationToken cancellationToken)
255255
{
256256
if (pipeline == null)
257257
{
@@ -260,8 +260,7 @@ internal async Task InitializeEndpointIfNecessary(ExecutionContext executionCont
260260
{
261261
if (pipeline == null)
262262
{
263-
var functionExecutionContext = new FunctionExecutionContext(executionContext, logger);
264-
endpoint = await endpointFactory(functionExecutionContext).ConfigureAwait(false);
263+
endpoint = await endpointFactory().ConfigureAwait(false);
265264

266265
pipeline = serverlessInterceptor.PipelineInvoker;
267266
}
@@ -276,7 +275,7 @@ internal async Task InitializeEndpointIfNecessary(ExecutionContext executionCont
276275
PipelineInvoker pipeline;
277276
IEndpointInstance endpoint;
278277

279-
readonly Func<FunctionExecutionContext, Task<IEndpointInstance>> endpointFactory;
278+
readonly Func<Task<IEndpointInstance>> endpointFactory;
280279
readonly SemaphoreSlim semaphoreLock = new SemaphoreSlim(initialCount: 1, maxCount: 1);
281280
readonly ServerlessInterceptor serverlessInterceptor;
282281
}

src/ServiceBus.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@
22
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo(@"ServiceBus.Tests, PublicKey=00240000048000009400000006020000002400005253413100040000010001007f16e21368ff041183fab592d9e8ed37e7be355e93323147a1d29983d6e591b04282e4da0c9e18bd901e112c0033925eb7d7872c2f1706655891c5c9d57297994f707d16ee9a8f40d978f064ee1ffc73c0db3f4712691b23bf596f75130f4ec978cf78757ec034625a5f27e6bb50c618931ea49f6f628fd74271c32959efb1c5")]
33
namespace NServiceBus
44
{
5-
public class FunctionExecutionContext
6-
{
7-
public FunctionExecutionContext(Microsoft.Azure.WebJobs.ExecutionContext executionContext, Microsoft.Extensions.Logging.ILogger logger) { }
8-
public Microsoft.Azure.WebJobs.ExecutionContext ExecutionContext { get; }
9-
public Microsoft.Extensions.Logging.ILogger Logger { get; }
10-
}
115
public static class FunctionsHostBuilderExtensions
126
{
137
public static void UseNServiceBus(this Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder functionsHostBuilder, System.Action<NServiceBus.ServiceBusTriggeredEndpointConfiguration> configurationFactory = null) { }

src/ServiceBus.Tests/When_shipping_handlers_in_dedicated_assembly.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public async Task Should_load_handlers_from_assembly_when_using_FunctionsHostBui
4242
var endpoint = new InProcessFunctionEndpoint(startableEndpoint, serverless, serviceProvider);
4343

4444
// we need to process an actual message to have the endpoint being created
45-
await endpoint.InitializeEndpointIfNecessary(new Microsoft.Azure.WebJobs.ExecutionContext(), null, CancellationToken.None);
45+
await endpoint.InitializeEndpointIfNecessary(CancellationToken.None);
4646

4747
// The message handler assembly should be loaded now because scanning should find and load the handler assembly
4848
Assert.True(AppDomain.CurrentDomain.GetAssemblies().Any(a => a.FullName == "Testing.Handlers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"));

0 commit comments

Comments
 (0)