Skip to content

Commit

Permalink
Add clusterModeEnabled to the ConnectionSettings
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Nov 15, 2023
1 parent e71a7ac commit 6f95345
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ public RunConfiguration() {
new ClientName[] {
// ClientName.BABUSHKA_ASYNC,
ClientName.JNI_NETTY
// ClientName.LETTUCE_ASYNC
// ClientName.LETTUCE_ASYNC
};
host = "localhost";
port = 6379;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public String getName() {

@Override
public void connectToRedis() {
connectToRedis(new ConnectionSettings("localhost", 6379, false));
connectToRedis(new ConnectionSettings("localhost", 6379, false, false));
}

@Override
Expand Down Expand Up @@ -381,7 +381,7 @@ public Future<Response> asyncConnectToRedis(ConnectionSettings connectionSetting
connectionSettings.useSsl // TODO: secure or insecure TLS?
? TlsMode.SecureTls
: TlsMode.NoTls)
.setClusterModeEnabled(false)
.setClusterModeEnabled(connectionSettings.clusterModeEnabled)
// In millis
.setResponseTimeout(250)
// In millis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ public class LettuceAsyncClient implements AsyncClient {

@Override
public void connectToRedis() {
connectToRedis(new ConnectionSettings("localhost", 6379, false));
connectToRedis(new ConnectionSettings("localhost", 6379, false, false));
}

@Override
public void connectToRedis(ConnectionSettings connectionSettings) {
assert connectionSettings.clusterModeEnabled == false
: "LettuceAsyncClient invalid with clusterModeEnabled, use LettuceAsyncClusterClient"
+ " instead";
client =
RedisClient.create(
String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,14 @@ public class LettuceAsyncClusterClient extends LettuceAsyncClient {

@Override
public void connectToRedis() {
connectToRedis(new ConnectionSettings("localhost", 6379, false));
connectToRedis(new ConnectionSettings("localhost", 6379, false, true));
}

@Override
public void connectToRedis(ConnectionSettings connectionSettings) {
assert connectionSettings.clusterModeEnabled == false
: "LettuceAsyncClusterClient invalid with clusterModeEnabled disabled, use"
+ " LettuceAsyncClient instead";
RedisURI uri =
RedisURI.builder()
.withHost(connectionSettings.host)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class LettuceClient implements SyncClient {

@Override
public void connectToRedis() {
connectToRedis(new ConnectionSettings("localhost", 6379, false));
connectToRedis(new ConnectionSettings("localhost", 6379, false, false));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ public static void testClientSetGet(
List<Client> clients = new LinkedList<>();
for (int cc = 0; cc < clientCount; cc++) {
Client newClient = clientCreator.get();
newClient.connectToRedis(new ConnectionSettings(config.host, config.port, config.tls));
newClient.connectToRedis(
new ConnectionSettings(
config.host, config.port, config.tls, config.clusterModeEnabled));
clients.add(newClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ public class ConnectionSettings {
public String host;
public int port;
public boolean useSsl;
public boolean clusterModeEnabled;

public ConnectionSettings(String host, int port, boolean useSsl) {
public ConnectionSettings(String host, int port, boolean useSsl, boolean clusterModeEnabled) {
this.host = host;
this.port = port;
this.useSsl = useSsl;
this.clusterModeEnabled = clusterModeEnabled;
}
}

0 comments on commit 6f95345

Please sign in to comment.