
io.dropwizard.redis.RedisClusterClientBundle 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
Provides easy integration for Dropwizard applications with Redis
The newest version!
package io.dropwizard.redis;
import brave.Tracing;
import io.dropwizard.core.Configuration;
import io.dropwizard.core.ConfiguredBundle;
import io.dropwizard.core.setup.Bootstrap;
import io.dropwizard.core.setup.Environment;
import io.lettuce.core.cluster.api.StatefulRedisClusterConnection;
import org.checkerframework.checker.nullness.qual.Nullable;
import static java.util.Objects.requireNonNull;
public abstract class RedisClusterClientBundle implements ConfiguredBundle {
@Nullable
private StatefulRedisClusterConnection clusterConnection;
@Override
public void initialize(final Bootstrap> bootstrap) {
// do nothing
}
@Override
public void run(final T configuration, final Environment environment) throws Exception {
final RedisClusterClientFactory redisClusterClientFactory = requireNonNull(getRedisClusterClientFactory(configuration));
final Tracing tracing = Tracing.current();
this.clusterConnection = redisClusterClientFactory.build(environment.healthChecks(), environment.lifecycle(), environment.metrics(),
tracing);
}
public abstract RedisClusterClientFactory getRedisClusterClientFactory(T configuration);
public StatefulRedisClusterConnection getClusterConnection() {
return requireNonNull(clusterConnection);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy