-
Notifications
You must be signed in to change notification settings - Fork 797
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
AzureServiceBus ensure client reuse #1974
AzureServiceBus ensure client reuse #1974
Conversation
…g/endpoint ConnectionKey should point to a service bus in order to reuse clients instead of pointing to a unique queue or subscription Added additional queue/subscription key for reusing reciever clients
@dotnet-policy-service agree company="Delegate A/S" |
…entCache" This reverts commit 60be56e.
...lthChecks.AzureServiceBus/DependencyInjection/AzureServiceBusHealthCheckBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
Previous commit introduced a new ServiceBusClientProvider which was added to all ServiceBus Health Check constructors. But this would introduce a breaking change. This commit would re-add constructors with 1 argument to allow for backward compatability.
test/HealthChecks.AzureServiceBus.Tests/HealthChecks.AzureServiceBus.approved.txt
Outdated
Show resolved
Hide resolved
…iceBus.approved.txt
src/HealthChecks.AzureServiceBus/AzureServiceBusQueueHealthCheck.cs
Outdated
Show resolved
Hide resolved
src/HealthChecks.AzureServiceBus/AzureServiceBusSubscriptionHealthCheck.cs
Outdated
Show resolved
Hide resolved
...lthChecks.AzureServiceBus.Tests/AzureServiceBusQueueMessageCountThresholdHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
...lthChecks.AzureServiceBus.Tests/AzureServiceBusQueueMessageCountThresholdHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
...lthChecks.AzureServiceBus.Tests/AzureServiceBusQueueMessageCountThresholdHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
...lthChecks.AzureServiceBus.Tests/AzureServiceBusQueueMessageCountThresholdHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
...lthChecks.AzureServiceBus.Tests/AzureServiceBusQueueMessageCountThresholdHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
test/HealthChecks.AzureServiceBus.Tests/AzureServiceBusSubscriptionHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
test/HealthChecks.AzureServiceBus.Tests/AzureServiceBusSubscriptionHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
test/HealthChecks.AzureServiceBus.Tests/AzureServiceBusTopicHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
@TomMalow I'm fine to merge after fixing all copy-paste issues. Thank you very much for exhaustive tests. |
also collect all values used to define a queue key together Change to field to avoid recalculation of the value each time
6de43bf
to
a2ac5a3
Compare
@sungam3r It should be ready now. Found some other similar mistakes that have been correct. |
Please bump |
test/HealthChecks.AzureServiceBus.Tests/AzureServiceBusQueueHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
…althCheckTests.cs
test/HealthChecks.AzureServiceBus.Tests/AzureServiceBusQueueHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
…althCheckTests.cs
test/HealthChecks.AzureServiceBus.Tests/AzureServiceBusQueueHealthCheckTests.cs
Outdated
Show resolved
Hide resolved
…althCheckTests.cs
FullyQualifiedNamespace = FullyQualifiedName, | ||
Credential = _tokenCredential, | ||
}; | ||
var otherHealthCheck = new AzureServiceBusQueueHealthCheck(options, _clientProvider); |
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.
var otherHealthCheck = new AzureServiceBusQueueHealthCheck(options, _clientProvider); | |
var otherHealthCheck = new AzureServiceBusQueueHealthCheck(otherOptions, _clientProvider); |
var otherHealthCheck = new AzureServiceBusQueueHealthCheck(options, _clientProvider); | ||
var otherContext = new HealthCheckContext | ||
{ | ||
Registration = new HealthCheckRegistration(HEALTH_CHECK_NAME, healthCheck, HealthStatus.Unhealthy, 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.
Registration = new HealthCheckRegistration(HEALTH_CHECK_NAME, healthCheck, HealthStatus.Unhealthy, null) | |
Registration = new HealthCheckRegistration(HEALTH_CHECK_NAME, otherHealthCheck, HealthStatus.Unhealthy, null) |
Registration = new HealthCheckRegistration(HEALTH_CHECK_NAME, healthCheck, HealthStatus.Unhealthy, null) | ||
}; | ||
|
||
var otherActual = await healthCheck |
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.
var otherActual = await healthCheck | |
var otherActual = await otherHealthCheck |
Please, look through test files one more time...
Some test was setup incorrectly but were not caught by in any assertion. Added som additional assert to ensure that healthchecks were executing as intended
HealthCheck was always called after setting it up in helper methods so to reduce boiler plate the call to health check is moved intothe helper method. Only a few had a substitute setup inbetween, but these could be moved to earlier in the respective tests
f60355d
to
9491eaf
Compare
Got tired of embarrassing myself, so ended up refactoring the tests to reduce the potential for me making, or overseeing, any mistakes. The test now has reduced boilerplate around setting up and executing the HealthChecks. This also resulted in the tests being much easier to read. |
@TomMalow I believe everything is OK now though I did not deep in each line this time. |
@@ -8,40 +8,46 @@ namespace HealthChecks.AzureServiceBus | |||
public abstract class AzureServiceBusHealthCheck<TOptions> | |||
where TOptions : HealthChecks.AzureServiceBus.Configuration.AzureServiceBusHealthCheckOptions | |||
{ | |||
protected static readonly System.Collections.Concurrent.ConcurrentDictionary<string, Azure.Messaging.ServiceBus.ServiceBusClient> ClientConnections; |
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.
Techically breaking changes, but I think v7.1 is OK.
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.
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #1974 +/- ##
==========================================
+ Coverage 66.35% 67.45% +1.09%
==========================================
Files 251 252 +1
Lines 8692 8729 +37
Branches 622 624 +2
==========================================
+ Hits 5768 5888 +120
+ Misses 2762 2677 -85
- Partials 162 164 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
What this PR does / why we need it:
HealthChecks.AzureServiceBus did not reuse created clients clients when possible.
Using multiple health check to queues and subscription within the same ServiceBus would resolve in multiple clients being created. Thereby experience a long first time execution of the health check and unnecessary open connections.
Which issue(s) this PR fixes:
#1890
Special notes for your reviewer:
I moved the code over to use the shared ClientCache instead of an internal cache. The internal cache did not allow for caching across health check instances.
The HealthChecks.AzureServiceBus did not have any unit test before. I have added for most of the health check except EventBus health check as it was not modified by this PR. This is due to the EventBus health check not face the same problem.
Does this PR introduce a user-facing change?:
Yes:
Prefix
field as been made obsolete and superseded by the existingConnectionKey
Please make sure you've completed the relevant tasks for this PR, out of the following list: