-
Notifications
You must be signed in to change notification settings - Fork 0
Spike function manifests #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@DavidBoike @mattmercurio this seems to work as intended. |
| { | ||
| entries.Add(new("ReceiverEndpoint", "ReceiverEndpoint", "AzureWebJobsServiceBus")); | ||
| entries.Add(new("AnotherReceiverEndpoint", "AnotherReceiverEndpoint", "AzureWebJobsServiceBus")); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this isn't generated the compiler is smart enough to just remove the call to it https://github.com/Particular/NServiceBus.AzureFunctions/pull/17/changes#diff-ee8c777d474fb183096f7268d8acc6fb6a653a75ef70b7eeba14423385352d0aR10
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/partial-member
A partial method isn't required to have an implementing declaration in the following cases:
It doesn't have any accessibility modifiers (including the default private).
It returns void.
It doesn't have any out parameters.
It doesn't have any of the following modifiers virtual, override, sealed, new, or extern.
d033c03 to
d8b8b1f
Compare
|
@DavidBoike @mattmercurio I have rebased and added a few more ideas. See comments inline |
| ConnectionName = "AzureWebJobsServiceBus" | ||
| }; | ||
|
|
||
| var routing = endpoint.UseTransport(transport); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Demo use of routing
| builder.Services.AddHostedService<InitializeLogger>(); | ||
|
|
||
| builder.AddNServiceBusFunction("SenderEndpoint", endpoint => | ||
| builder.AddSendOnlyNServiceBusEndpoint("SenderEndpoint", endpoint => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a separate code path for send-only seems to make validation and other things much cleaner
| var transport = new AzureServiceBusServerlessTransport(TopicTopology.Default) | ||
| { | ||
| //send only endpoints might need to set the connection name | ||
| ConnectionName = "AzureWebJobsServiceBus" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the use case where users might want to control the connection name, if so we might want to add this option to AddSendOnlyNServiceBusEndpoint and not on the transport definition
| public Task Receiver( | ||
| [ServiceBusTrigger("ReceiverEndpoint", Connection = "AzureWebJobsServiceBus", AutoCompleteMessages = true)] | ||
| ServiceBusReceivedMessage message, | ||
| ServiceBusMessageActions messageActions, FunctionContext context, CancellationToken cancellationToken = default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These were leftovers from the old repo and is, at least currently, not needed
|
|
||
| using Microsoft.Extensions.Hosting; | ||
|
|
||
| public class FunctionConfigurationValidator : IHostedService |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sure that all functions that we found have been configured by the user
| configure(endpointConfiguration); | ||
|
|
||
| var settings = endpointConfiguration.GetSettings(); | ||
| if (settings.GetOrDefault<bool>(AzureServiceBusServerlessTransport.SendOnlyConfigKey)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have a separate code path for send-only we can guard here
|
|
||
| var functionManifest = FunctionsRegistry.GetAll().SingleOrDefault(f => f.Name.Equals(endpointName, StringComparison.InvariantCultureIgnoreCase)); | ||
|
|
||
| if (functionManifest is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since send only is on a different code path we must have a correcsponding function at this stage
| endpointConfiguration.SendOnly(); | ||
|
|
||
| // Make sure that the correct transport is used | ||
| _ = GetTransport(endpointConfiguration.GetSettings()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugly but gets the job done for now to make sure that the user has configured a AzureServiceBusServerlessTransport
| await endpointStarter.GetOrStart(cancellationToken).ConfigureAwait(false); | ||
| await transport.MessageProcessor.Process(message, messageActions, cancellationToken).ConfigureAwait(false); | ||
|
|
||
| if (transport.MessageProcessor is null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this new world we can never come here unless the user has configured a non-send-only endpoint but we are guaarding anyway for completeness
| @@ -0,0 +1,12 @@ | |||
| namespace NServiceBus; | |||
|
|
|||
| static partial class FunctionsRegistry | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DavidBoike now I get what you meant yesterday, this code will be generated in the user assembly and not here so this won't work.
I have another idea, stay tuned
No description provided.