arcus-azure/arcus.messaging

Provide an Async method for registering Azure clients

Closed this issue · 2 comments

We currently have methods like AddEventHubProducerClient that take a secret-name as an argument. These methods will use the registered ISecretProvider to retrieve the secret that is necessary to instantiate the client that we want to add to the DI container.

In the documentation of the Arcus template I read this warning:

The Azure EventHubs connection string will be retrieved synchronously, so make sure that you register your connection string secret in a secret provider that supports synchronous secret retrieval

This is something the end-user has no control over. Suppose someone uses a secret provider that doesn't support sync secret retrieval, then the user is blocked ?
Should we consider adding a AddEventHubProducerClientAsync method which retrieves the secret in an async way ? (Or some other solution for this ?)

It was the point that we used the sync-variants for this, of course. It is the responsibility of the dev, in this case. Adding a ...Async variant would make this rather complicated, I think. We could maybe provide a 'fallback' to still use the .GetAwaiter().GetResult() if the sync-variant does not result in any result?

Falling back to an async secret retrieval can indeed be a solution for this. The consumer then also doesn't need to worry about this.