Created
September 10, 2019 14:56
-
-
Save ntakouris/15831f0bc21f5dd26e22bb30d1e7c110 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RedisHealthCheck : IHealthCheck | |
{ | |
private readonly IConnectionMultiplexer _connectionMultiplexer; | |
public RedisHealthCheck(IConnectionMultiplexer connectionMultiplexer) | |
{ | |
_connectionMultiplexer = connectionMultiplexer; | |
} | |
public Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken()) | |
{ | |
try | |
{ | |
var database = _connectionMultiplexer.GetDatabase(); | |
database.StringGet("health"); | |
return Task.FromResult(HealthCheckResult.Healthy()); | |
} | |
catch (Exception exception) | |
{ | |
return Task.FromResult(HealthCheckResult.Unhealthy(exception.Message)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment