Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for password in JedisPooled initialization #2100

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
package org.springframework.ai.autoconfigure.vectorstore.redis;

import io.micrometer.observation.ObservationRegistry;
import redis.clients.jedis.DefaultJedisClientConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisClientConfig;
import redis.clients.jedis.JedisPooled;

import org.springframework.ai.embedding.BatchingStrategy;
Expand All @@ -40,6 +43,7 @@
* @author Christian Tzolov
* @author Eddú Meléndez
* @author Soby Chacko
* @author Jihoon Kim
*/
@AutoConfiguration(after = RedisAutoConfiguration.class)
@ConditionalOnClass({ JedisPooled.class, JedisConnectionFactory.class, RedisVectorStore.class, EmbeddingModel.class })
Expand All @@ -60,8 +64,7 @@ public RedisVectorStore vectorStore(EmbeddingModel embeddingModel, RedisVectorSt
ObjectProvider<VectorStoreObservationConvention> customObservationConvention,
BatchingStrategy batchingStrategy) {

JedisPooled jedisPooled = new JedisPooled(jedisConnectionFactory.getHostName(),
jedisConnectionFactory.getPort());
JedisPooled jedisPooled = this.jedisPooled(jedisConnectionFactory);
return RedisVectorStore.builder(jedisPooled, embeddingModel)
.initializeSchema(properties.isInitializeSchema())
.observationRegistry(observationRegistry.getIfUnique(() -> ObservationRegistry.NOOP))
Expand All @@ -72,4 +75,19 @@ public RedisVectorStore vectorStore(EmbeddingModel embeddingModel, RedisVectorSt
.build();
}

private JedisPooled jedisPooled(JedisConnectionFactory jedisConnectionFactory) {

String host = jedisConnectionFactory.getHostName();
int port = jedisConnectionFactory.getPort();

JedisClientConfig clientConfig = DefaultJedisClientConfig.builder()
.ssl(jedisConnectionFactory.isUseSsl())
.clientName(jedisConnectionFactory.getClientName())
.timeoutMillis(jedisConnectionFactory.getTimeout())
.password(jedisConnectionFactory.getPassword())
.build();

return new JedisPooled(new HostAndPort(host, port), clientConfig);
}

}
Loading