use of io.lettuce.core.resource.ClientResources in project lettuce-core by lettuce-io.
the class RedisClientIntegrationTests method managedClientResources.
@Test
void managedClientResources() throws Exception {
// given
RedisClient redisClient1 = RedisClient.create(RedisURI.create(TestSettings.host(), TestSettings.port()));
ClientResources clientResources = redisClient1.getResources();
Map<Class<? extends EventExecutorGroup>, EventExecutorGroup> eventLoopGroups = getExecutors(clientResources);
connectAndClose(redisClient1);
// when
EventExecutorGroup executor = eventLoopGroups.values().iterator().next();
redisClient1.shutdown(0, 0, TimeUnit.MILLISECONDS);
// then
assertThat(eventLoopGroups).isEmpty();
assertThat(executor.isShuttingDown()).isTrue();
assertThat(clientResources.eventExecutorGroup().isShuttingDown()).isTrue();
}
use of io.lettuce.core.resource.ClientResources in project spring-boot by spring-projects.
the class LettuceMetricsAutoConfigurationTests method whenThereIsAMeterRegistryThenCommandLatencyRecorderIsAdded.
@Test
void whenThereIsAMeterRegistryThenCommandLatencyRecorderIsAdded() {
this.contextRunner.with(MetricsRun.simple()).withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class)).run((context) -> {
ClientResources clientResources = context.getBean(LettuceConnectionFactory.class).getClientResources();
assertThat(clientResources.commandLatencyRecorder()).isInstanceOf(MicrometerCommandLatencyRecorder.class);
});
}
use of io.lettuce.core.resource.ClientResources in project spring-boot by spring-projects.
the class LettuceMetricsAutoConfigurationTests method whenThereIsNoMeterRegistryThenClientResourcesCustomizationBacksOff.
@Test
void whenThereIsNoMeterRegistryThenClientResourcesCustomizationBacksOff() {
this.contextRunner.withConfiguration(AutoConfigurations.of(RedisAutoConfiguration.class)).run((context) -> {
ClientResources clientResources = context.getBean(LettuceConnectionFactory.class).getClientResources();
assertThat(clientResources.commandLatencyRecorder()).isNotInstanceOf(MicrometerCommandLatencyRecorder.class);
});
}
use of io.lettuce.core.resource.ClientResources in project lettuce-core by lettuce-io.
the class LettuceCdiExtension method processBean.
/**
* Implementation of a an observer which checks for RedisURI beans and stores them in {@link #redisUris} for later
* association with corresponding repository beans.
*
* @param <T> The type.
* @param processBean The annotated type as defined by CDI.
*/
@SuppressWarnings("unchecked")
<T> void processBean(@Observes ProcessBean<T> processBean) {
Bean<T> bean = processBean.getBean();
for (Type type : bean.getTypes()) {
if (!(type instanceof Class<?>)) {
continue;
}
// Check if the bean is an RedisURI.
if (RedisURI.class.isAssignableFrom((Class<?>) type)) {
Set<Annotation> qualifiers = LettuceSets.newHashSet(bean.getQualifiers());
if (bean.isAlternative() || !redisUris.containsKey(qualifiers)) {
LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", RedisURI.class.getName(), qualifiers));
redisUris.put(qualifiers, (Bean<RedisURI>) bean);
}
}
if (ClientResources.class.isAssignableFrom((Class<?>) type)) {
Set<Annotation> qualifiers = LettuceSets.newHashSet(bean.getQualifiers());
if (bean.isAlternative() || !clientResources.containsKey(qualifiers)) {
LOGGER.debug(String.format("Discovered '%s' with qualifiers %s.", ClientResources.class.getName(), qualifiers));
clientResources.put(qualifiers, (Bean<ClientResources>) bean);
}
}
}
}
use of io.lettuce.core.resource.ClientResources in project lettuce-core by lettuce-io.
the class RedisClientCdiBean method create.
@Override
public RedisClient create(CreationalContext<RedisClient> creationalContext) {
CreationalContext<RedisURI> uriCreationalContext = beanManager.createCreationalContext(redisURIBean);
RedisURI redisURI = (RedisURI) beanManager.getReference(redisURIBean, RedisURI.class, uriCreationalContext);
if (clientResourcesBean != null) {
ClientResources clientResources = (ClientResources) beanManager.getReference(clientResourcesBean, ClientResources.class, uriCreationalContext);
return RedisClient.create(clientResources, redisURI);
}
return RedisClient.create(redisURI);
}
Aggregations