-
Notifications
You must be signed in to change notification settings - Fork 798
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
Fix connections leak in RabbitMQHealthCheck #2048
Fix connections leak in RabbitMQHealthCheck #2048
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
Add unit test for once creation
Hi @Vladimirezh Let me some days to review. |
Codecov Report
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. @@ Coverage Diff @@
## master #2048 +/- ##
==========================================
- Coverage 69.06% 65.57% -3.49%
==========================================
Files 179 174 -5
Lines 4613 4099 -514
Branches 447 400 -47
==========================================
- Hits 3186 2688 -498
+ Misses 1323 1321 -2
+ Partials 104 90 -14
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Hi @Vladimirezh Thanks for submit this PR, just a few notes
|
Hi @Vladimirezh Just curious about your code.. some notes... If you registered the IConnection as a Singleton and use the overload you mention like this
var connectionFactory = new ConnectionFactory
{
Uri = new Uri("amqp://localhost:5672")
};
services.AddSingleton<IConnection>(connectionFactory.CreateConnection());
services
.AddHealthChecks()
.AddRabbitMQ((sp, options) =>
options.Connection = sp.GetRequiredService<IConnection>(), name: "rabbit1"); just one connection is used Why you need to register a Func of IConnection? |
I have custom connection factory. Factory doesn't implement IConnectionFactory. In example it's Func, in my project it's library abstraction. I use overload with setup and set connection to options. |
@Vladimirezh Proposed changes will not work for multiple registrations. You register RabbitMQHealthCheck as singleton in method accepting user defined If you look in the code in ping @adamsitnik It seems to me that we have similar problems with some other checks. Did you fix this with Npgsql or was there something else? I still have not returned to the full support of the project, so I have not studied your changes. |
What this PR does / why we need it:
Every call of healthcheck create new connection. Connection doesn't close.
Which issue(s) this PR fixes:
Please reference the issue this PR will close: #[issue number]
Special notes for your reviewer:
Does this PR introduce a user-facing change?:
No
Please make sure you've completed the relevant tasks for this PR, out of the following list: