-
Notifications
You must be signed in to change notification settings - Fork 801
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
Features/add raven db health check #77
Features/add raven db health check #77
Conversation
Hi @Burgyn Can you check why build is not passed? |
Hi. Of course. Actually, I fixed it. I will push new change tomorrow. I apologize. |
Is ok, no worries!! |
README.md
Outdated
@@ -35,6 +35,7 @@ HealthChecks packages include health checks for: | |||
- Uri: single uri and uri groups | |||
- Consul | |||
- Hangfire | |||
- RavenDB |
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 it would be better adding RavenBD close to the other database healthchecks (mysql, oracle, sqlite, postgres)
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 will do, Thanks.
} | ||
|
||
[Fact] | ||
public async Task be_healthy_if_ravendb_isnot_available() |
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.
_is_not
private readonly string _connectionString; | ||
private readonly string _specifiedDatabase; | ||
|
||
/// <summary> |
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.
We don't have comments on HealthChecks because probably is not used directly never.
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.
Ok
}) | ||
{ | ||
store.Initialize(); | ||
var databases = await store.Maintenance.Server.SendAsync(new GetDatabaseNamesOperation(0, 100)); |
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.
what is the meaning of 0, 100 parameters?
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 means that the server sends the first 100 existing database names. I know that if it checks the database name and has more than 100 databases it can fail. But, according to my experience, it is unlikely that it has more than 100 databases under one server.
if (!string.IsNullOrWhiteSpace(_specifiedDatabase) | ||
&& !databases.Contains(_specifiedDatabase, StringComparer.OrdinalIgnoreCase)) | ||
{ | ||
return HealthCheckResult.Unhealthy($"RavenDB doesn't contains '{_specifiedDatabase}' database."); |
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.
Don't use Unhealthy, use HealthCheckResult(context.Registration.FailureStatus, exception: ex) to enable de developer to set the invalid state for this health check.
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 don't have exception. So I return: return new HealthCheckResult( context.Registration.FailureStatus, $"RavenDB doesn't contains '{_specifiedDatabase}' database.");
I'm not sure. It's 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.
yeap, the idea is honored FailureStatus configuration.
Merged with some minor changes. Thanks for contribute @Burgyn |
You are welcome. |
This PR adds HealthCheck for RavenDB.
I have created a new
HealthChecks.RavenDB
project with unit and functional tests.Close #76