
com.bendb.dropwizard.redis.JedisHealthCheck Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dropwizard-redis Show documentation
Show all versions of dropwizard-redis Show documentation
Addon bundle for Dropwizard to support use of Redis
package com.bendb.dropwizard.redis;
import com.codahale.metrics.health.HealthCheck;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
public class JedisHealthCheck extends HealthCheck {
private final JedisPool pool;
public JedisHealthCheck(JedisPool pool) {
this.pool = pool;
}
@Override
protected Result check() throws Exception {
try (Jedis jedis = pool.getResource()) {
final String pong = jedis.ping();
if ("PONG".equals(pong)) {
return Result.healthy();
}
}
return Result.unhealthy("Could not ping redis");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy