use of org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder in project spring-boot by spring-projects.
the class LettuceConnectionConfiguration method getLettuceClientConfiguration.
private LettuceClientConfiguration getLettuceClientConfiguration(ObjectProvider<LettuceClientConfigurationBuilderCustomizer> builderCustomizers, ClientResources clientResources, Pool pool) {
LettuceClientConfigurationBuilder builder = createBuilder(pool);
applyProperties(builder);
if (StringUtils.hasText(getProperties().getUrl())) {
customizeConfigurationFromUrl(builder);
}
builder.clientOptions(createClientOptions());
builder.clientResources(clientResources);
builderCustomizers.orderedStream().forEach((customizer) -> customizer.customize(builder));
return builder.build();
}
use of org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder in project dhis2-core by dhis2.
the class RedisConfiguration method lettuceConnectionFactory.
@Bean
public LettuceConnectionFactory lettuceConnectionFactory() {
LettuceClientConfigurationBuilder builder = LettuceClientConfiguration.builder();
if (DhisConfigurationProvider.isOn((String) redisSslEnabled().getObject())) {
builder.useSsl();
}
LettuceClientConfiguration clientConfiguration = builder.build();
RedisStandaloneConfiguration standaloneConfig = new RedisStandaloneConfiguration();
standaloneConfig.setHostName((String) redisHost().getObject());
standaloneConfig.setPassword((String) redisPassword().getObject());
standaloneConfig.setPort(Integer.parseInt((String) redisPort().getObject()));
return new LettuceConnectionFactory(standaloneConfig, clientConfiguration);
}
use of org.springframework.data.redis.connection.lettuce.LettuceClientConfiguration.LettuceClientConfigurationBuilder in project spring-cloud-connectors by spring-cloud.
the class RedisConnectionFactoryCreator method create.
@Override
public RedisConnectionFactory create(RedisServiceInfo serviceInfo, ServiceConnectorConfig serviceConnectorConfig) {
RedisStandaloneConfiguration configuration = new RedisStandaloneConfiguration();
configuration.setHostName(serviceInfo.getHost());
configuration.setPort(serviceInfo.getPort());
configuration.setPassword(RedisPassword.of(serviceInfo.getPassword()));
if (hasClass(JEDIS_CLASS_NAME)) {
JedisClientConfigurationBuilder builder = JedisClientConfiguration.builder();
RedisJedisClientConfigurer clientConfigurer = new RedisJedisClientConfigurer();
if (serviceConnectorConfig instanceof RedisConnectionFactoryConfig) {
clientConfigurer.configure(builder, (RedisConnectionFactoryConfig) serviceConnectorConfig);
} else {
clientConfigurer.configure(builder, (PooledServiceConnectorConfig) serviceConnectorConfig);
}
if (connectionIsSecure(serviceInfo)) {
builder.useSsl();
}
JedisConnectionFactory connectionFactory = new JedisConnectionFactory(configuration, builder.build());
connectionFactory.afterPropertiesSet();
return connectionFactory;
} else if (hasClass(LETTUCE_CLASS_NAME)) {
LettuceClientConfigurationBuilder builder;
if (serviceConnectorConfig != null && ((PooledServiceConnectorConfig) serviceConnectorConfig).getPoolConfig() != null) {
if (!hasClass(APACHE_COMMONS_POOL_CLASS_NAME)) {
throw new ServiceConnectorCreationException(String.format("Failed to create cloud Redis " + "connection factory for %s service. Apache Commons Pool must be available on " + "the classpath if pooling parameters are provided.", serviceInfo.getId()));
}
builder = LettucePoolingClientConfiguration.builder();
} else {
builder = LettuceClientConfiguration.builder();
}
if (connectionIsSecure(serviceInfo)) {
builder.useSsl();
}
RedisLettuceClientConfigurer clientConfigurer = new RedisLettuceClientConfigurer();
if (serviceConnectorConfig instanceof RedisConnectionFactoryConfig) {
clientConfigurer.configure(builder, (RedisConnectionFactoryConfig) serviceConnectorConfig);
} else {
clientConfigurer.configure(builder, (PooledServiceConnectorConfig) serviceConnectorConfig);
}
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(configuration, builder.build());
connectionFactory.afterPropertiesSet();
return connectionFactory;
} else {
throw new ServiceConnectorCreationException(String.format("Failed to create cloud Redis " + "connection factory for %s service. No client implementation classes " + " of Jedis or Lettuce clients implementation (%s, %s) not found", serviceInfo.getId(), JEDIS_CLASS_NAME, LETTUCE_CLASS_NAME));
}
}
Aggregations