Skip to content
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

Added implementation to support EventHubBufferedProducerClient #3833

Merged
merged 12 commits into from
Aug 17, 2024

Conversation

WhitWaldo
Copy link
Contributor

@WhitWaldo WhitWaldo commented Apr 19, 2024

Implemented my own ask from #3832 to support the EventHubBufferedProducerClient in addition to the EventHubProducerClient as part of the Aspire DI registration.

Microsoft Reviewers: Open in CodeFlow

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-integrations Issues pertaining to Aspire Integrations packages label Apr 19, 2024
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Apr 19, 2024
@eerhardt
Copy link
Member

@WhitWaldo - it looks like the tests are failing. Can you fix them?

@WhitWaldo
Copy link
Contributor Author

@eerhardt Fixed

@eerhardt
Copy link
Member

@sebastienros - can you take a look at this?

@skolima
Copy link

skolima commented Aug 9, 2024

👋 @WhitWaldo - I'm looking at the same piece of functionality missing. Would you intend to bring this up to date, or are you ok with someone else updating it?

@WhitWaldo
Copy link
Contributor Author

@skolima I can bring it up to date over the weekend. It just fell off my radar!

@WhitWaldo
Copy link
Contributor Author

This has been updated and should be ready to go now!

@eerhardt
Copy link
Member

@sebastienros - can you take a look?

/// <param name="configureClientBuilder">An optional method that can be used for customizing the <see cref="IAzureClientBuilder{TClient, TOptions}"/>.</param>
/// <remarks>Reads the configuration from "Aspire:Azure:Messaging:EventHubs:{TClient}" section, where {TClient} is the type of Event Hubs client being configured, i.e. EventProcessorClient.</remarks>
/// <exception cref="InvalidOperationException">Thrown when neither <see cref="AzureMessagingEventHubsSettings.ConnectionString"/> nor <see cref="AzureMessagingEventHubsSettings.FullyQualifiedNamespace"/> is provided.</exception>
public static void AddKeyedAzureEventHubBufferedProducerClient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - when do we return the builder from such a method, and when do we use void?
cc @sebastienros @eerhardt

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave that philosophy to others, but here I'm just mirroring the return type taken for the existing extensions (void).


protected override void BindClientOptionsToConfiguration(IAzureClientBuilder<EventHubBufferedProducerClient, EventHubBufferedProducerClientOptions> clientBuilder, IConfiguration configuration)
{
#pragma warning disable IDE0200 // Remove unnecessary lambda expression - needed so the ConfigBinder Source Generator works
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious - what is this about? Is it a bug in the source generator that we are working around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I simply copied the approach taken in the existing consumer client component. I don't know what it is it's referring to, but if it's necessary there, I figured it should be included in this class as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

configuration.Bind is replaced at compiled time by a source generated version. But if you use a method group then the source generator doesn't kick in. To see the code expand the project like this:

image

Look for a method named Bind_EventHubBufferedProducerClientOptions and check the attribute on it that will point to the method to switch for.

@WhitWaldo
Copy link
Contributor Author

All Aspire.Azure.Messaging.EventHubs.Tests are passing on my system and I believe I've spoken to each of the reviews above.

@sebastienros
Copy link
Member

I think the only thing missing is updating the README to list the new client/settings. Just do a quick search for ProducerClient for the missing mentions.

@sebastienros
Copy link
Member

@WhitWaldo I did the required changes in the README.

@sebastienros sebastienros enabled auto-merge (squash) August 16, 2024 16:31
@radical
Copy link
Member

radical commented Aug 16, 2024

/azp run

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@radical
Copy link
Member

radical commented Aug 16, 2024

Multiple tests failing like this (log):

Aspire.Azure.Messaging.EventHubs.Tests.AspireEventHubsExtensionsTests.CanAddMultipleKeyedServices(clientIndex: 2) [FAIL]
  System.InvalidOperationException : No service for type 'Azure.Messaging.EventHubs.EventProcessorClient' has been registered.
  Stack Trace:
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetRequiredKeyedService(Type serviceType, Object serviceKey, ServiceProviderEngineScope serviceProviderEngineScope)
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetRequiredKeyedService(Type serviceType, Object serviceKey)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService(IServiceProvider provider, Type serviceType, Object serviceKey)
    /_/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs(259,0): at Aspire.Azure.Messaging.EventHubs.Tests.AspireEventHubsExtensionsTests.RetrieveClient(Object key, Int32 clientIndex, IHost host)
    /_/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs(361,0): at Aspire.Azure.Messaging.EventHubs.Tests.AspireEventHubsExtensionsTests.CanAddMultipleKeyedServices(Int32 clientIndex)
       at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
       at System.Reflection.MethodBaseInvoker.InvokeDirectByRefWithFewArgs(Object obj, Span`1 copyOfArgs, BindingFlags invokeAttr)
Aspire.Azure.Messaging.EventHubs.Tests.AspireEventHubsExtensionsTests.CanAddMultipleKeyedServices(clientIndex: 3) [FAIL]
  System.InvalidOperationException : No service for type 'Azure.Messaging.EventHubs.Primitives.PartitionReceiver' has been registered.
  Stack Trace:
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetRequiredKeyedService(Type serviceType, Object serviceKey, ServiceProviderEngineScope serviceProviderEngineScope)
       at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetRequiredKeyedService(Type serviceType, Object serviceKey)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderKeyedServiceExtensions.GetRequiredKeyedService(IServiceProvider provider, Type serviceType, Object serviceKey)
    /_/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs(259,0): at Aspire.Azure.Messaging.EventHubs.Tests.AspireEventHubsExtensionsTests.RetrieveClient(Object key, Int32 clientIndex, IHost host)
    /_/tests/Aspire.Azure.Messaging.EventHubs.Tests/AspireEventHubsExtensionsTests.cs(361,0): at Aspire.Azure.Messaging.EventHubs.Tests.AspireEventHubsExtensionsTests.CanAddMultipleKeyedServices(Int32 clientIndex)
       at InvokeStub_AspireEventHubsExtensionsTests.CanAddMultipleKeyedServices(Object, Span`1)
       at System.Reflection.MethodBaseInvoker.InvokeWithOneArg(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)

@WhitWaldo
Copy link
Contributor Author

Multiple tests failing like this (log):

Out of curiosity, is there any way to access that log without being a part of Microsoft? The tests passed locally but I saw the bot report a failure and I couldn't figure out how to access the log myself.

@radical
Copy link
Member

radical commented Aug 16, 2024

Multiple tests failing like this (log):

Out of curiosity, is there any way to access that log without being a part of Microsoft? The tests passed locally but I saw the bot report a failure and I couldn't figure out how to access the log myself.

Are you not able to access that link? I pasted the failures here anyway - https://gist.github.com/radical/1f55987361a1a828b3ed888b081e2dbe .

auto-merge was automatically disabled August 16, 2024 21:54

Head branch was pushed to by a user without write access

@WhitWaldo
Copy link
Contributor Author

WhitWaldo commented Aug 16, 2024

When I ran the tests locally before, I believe I ran them against the wrong branch. Re-resolved the comments above on the correct branch this time and fixed the unit tests + added inline tests for the new class to the mix. Now, they're all passing locally.

@WhitWaldo
Copy link
Contributor Author

Multiple tests failing like this (log):

Out of curiosity, is there any way to access that log without being a part of Microsoft? The tests passed locally but I saw the bot report a failure and I couldn't figure out how to access the log myself.

Are you not able to access that link? I pasted the failures here anyway - https://gist.github.com/radical/1f55987361a1a828b3ed888b081e2dbe .

I can access the link you provided, but is there any way to access those logs from the failed check itself (e.g. assuming I don't have access to the azdo environment)?

@radical
Copy link
Member

radical commented Aug 16, 2024

< snip />
I can access the link you provided, but is there any way to access those logs from the failed check itself (e.g. assuming I don't have access to the azdo environment)?

When the checks complete then you can see the details, and links to the failures in Build Analysis under Checks.

Copy link
Member

@radical radical left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other than the one comment, LGTM!

@sebastienros sebastienros merged commit 16c8d49 into dotnet:main Aug 17, 2024
11 checks passed
@WhitWaldo WhitWaldo deleted the eventhub-buffered-producer branch August 17, 2024 02:20
@github-actions github-actions bot locked and limited conversation to collaborators Sep 16, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-integrations Issues pertaining to Aspire Integrations packages community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants