Skip to content

Commit ad10c52

Browse files
committed
Simplify ExampleApp
Signed-off-by: Andrew Carbonetto <[email protected]>
1 parent ca8dda5 commit ad10c52

File tree

1 file changed

+12
-41
lines changed

1 file changed

+12
-41
lines changed

java/examples/src/main/java/glide/examples/ExamplesApp.java

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,30 @@
22
package glide.examples;
33

44
import glide.api.RedisClient;
5-
import glide.api.RedisClusterClient;
6-
import glide.examples.clients.GlideClient;
7-
import glide.examples.clients.GlideClusterClient;
5+
import glide.api.models.configuration.NodeAddress;
6+
import glide.api.models.configuration.RedisClientConfiguration;
87
import java.util.concurrent.ExecutionException;
98

109
public class ExamplesApp {
1110

1211
// main application entrypoint
1312
public static void main(String[] args) {
1413
runGlideExamples();
15-
16-
// uncomment to test against a Redis instance with cluster-mode enabled
17-
// runGlideClusterModeExamples();
1814
}
1915

2016
private static void runGlideExamples() {
21-
ConnectionSettings settings = new ConnectionSettings("localhost", 6379, false, false);
17+
String host = "localhost";
18+
Integer port = 6379;
19+
boolean useSsl = false;
20+
21+
RedisClientConfiguration config =
22+
RedisClientConfiguration.builder()
23+
.address(NodeAddress.builder().host(host).port(port).build())
24+
.useTLS(useSsl)
25+
.build();
2226

2327
try {
24-
RedisClient client = GlideClient.connectToGlide(settings);
28+
RedisClient client = RedisClient.CreateClient(config).get();
2529

2630
System.out.println("Glide PING: " + client.ping().get());
2731
System.out.println("Glide PING: " + client.ping("found you").get());
@@ -31,37 +35,4 @@ private static void runGlideExamples() {
3135
e.printStackTrace();
3236
}
3337
}
34-
35-
private static void runGlideClusterModeExamples() {
36-
ConnectionSettings settings = new ConnectionSettings("localhost", 8000, false, true);
37-
38-
try {
39-
RedisClusterClient client = GlideClusterClient.connectToGlide(settings);
40-
41-
System.out.println("Glide PING: ");
42-
System.out.println(">>>> " + client.ping().get());
43-
44-
System.out.println("Glide PING(msg): ");
45-
System.out.println(">>>> " + client.ping("msg").get());
46-
47-
} catch (ExecutionException | InterruptedException e) {
48-
System.out.println("Glide example failed with an exception: ");
49-
e.printStackTrace();
50-
}
51-
}
52-
53-
/** Redis-client settings */
54-
public static class ConnectionSettings {
55-
public final String host;
56-
public final int port;
57-
public final boolean useSsl;
58-
public final boolean clusterMode;
59-
60-
public ConnectionSettings(String host, int port, boolean useSsl, boolean clusterMode) {
61-
this.host = host;
62-
this.port = port;
63-
this.useSsl = useSsl;
64-
this.clusterMode = clusterMode;
65-
}
66-
}
6738
}

0 commit comments

Comments
 (0)