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

Port Resolving Support in Spring-Data-Redis for Jedis #2781

Open
anish8129 opened this issue Nov 20, 2023 · 2 comments
Open

Port Resolving Support in Spring-Data-Redis for Jedis #2781

anish8129 opened this issue Nov 20, 2023 · 2 comments
Assignees
Labels
type: enhancement A general enhancement

Comments

@anish8129
Copy link

anish8129 commented Nov 20, 2023

Hi,
I am trying to Test Redis Cluster Using TestContaienrs.
I have used lettuce to test, which actually requires Manual NAT port mapping to resolve the SocketAddress.

Here is an example: RedisConfig.java

Requirement

I want to have similar support for jedis as well in Spring-Data-Redis.

Proposing Implementation

After going through the code I noticed this redis.clients.jedis.HostAndPortMapper class
which we could use in the org.springframework.data.redis.connection.jedis.JedisClientConfiguration.

We need to add this new contract in the JedisClientConfiguration

/**
 * @return the optional {@link HostAndPortMapper}.
 */
 Optional<HostAndPortMapper> getHostAndPortMapper();

This will be implemented by the default DefaultJedisClientConfigurationBuilder

Implementation

I have tried this change on my local and tested as well.
PR #2780 is the change I am proposing.

Sample Example

A sample example of how to use it is added in this repo
Files to look for in this 👆 repo.
JedisClusterBasedIntegrationTest.java
RedisClusterTestContainer.java
JedisClusterTestContainer.java

NOTE:

Please suggest a better way to handle this in jedis if it already exist.

@junghoon-vans
Copy link
Contributor

When connecting to a Redis cluster, you can use RedisClusterConfiguration.
Have you tried the following methods?

@anish8129
Copy link
Author

anish8129 commented Nov 22, 2023

When connecting to a Redis cluster, you can use RedisClusterConfiguration. Have you tried the following methods?

Yes I have used RedisClusterConfiguation when I am connecting to redis cluster.
here is snippet link from the example project which I have mentioned in the description.
https://github.com/anish8129/prom-service/blob/4caefa13d23728d80058a34b0b36aa5d8a12fe00/src/main/java/com/redis/util/RedisBeanUtils.java#L60-L67

@mp911de mp911de added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Nov 27, 2023
@mp911de mp911de self-assigned this Nov 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants