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

Java: rename CreateClient to createClient #1828

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void connectToRedis(ConnectionSettings connectionSettings) {
.useTLS(connectionSettings.useSsl)
.build();
try {
redisClient = RedisClusterClient.CreateClient(config).get(10, SECONDS);
redisClient = RedisClusterClient.createClient(config).get(10, SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
Expand All @@ -50,7 +50,7 @@ public void connectToRedis(ConnectionSettings connectionSettings) {
.build();

try {
redisClient = RedisClient.CreateClient(config).get(10, SECONDS);
redisClient = RedisClient.createClient(config).get(10, SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
Expand Down
2 changes: 1 addition & 1 deletion java/client/src/main/java/glide/api/BaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ protected static class ClientBuilder {
* @param <T> Client type.
* @return a Future to connect and return a RedisClient.
*/
protected static <T extends BaseClient> CompletableFuture<T> CreateClient(
protected static <T extends BaseClient> CompletableFuture<T> createClient(
@NonNull BaseClientConfiguration config, Function<ClientBuilder, T> constructor) {
try {
ThreadPoolResource threadPoolResource = config.getThreadPoolResource();
Expand Down
8 changes: 4 additions & 4 deletions java/client/src/main/java/glide/api/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
import org.apache.commons.lang3.ArrayUtils;

/**
* Async (non-blocking) client for Redis in Standalone mode. Use {@link #CreateClient} to request a
* Async (non-blocking) client for Redis in Standalone mode. Use {@link #createClient} to request a
* client to Redis.
*/
public class RedisClient extends BaseClient
Expand All @@ -76,7 +76,7 @@ public class RedisClient extends BaseClient
TransactionsCommands {

/**
* A constructor. Use {@link #CreateClient} to get a client. Made protected to simplify testing.
* A constructor. Use {@link #createClient} to get a client. Made protected to simplify testing.
*/
protected RedisClient(ClientBuilder builder) {
super(builder);
Expand All @@ -88,9 +88,9 @@ protected RedisClient(ClientBuilder builder) {
* @param config Redis client Configuration.
* @return A Future to connect and return a RedisClient.
*/
public static CompletableFuture<RedisClient> CreateClient(
public static CompletableFuture<RedisClient> createClient(
@NonNull RedisClientConfiguration config) {
return CreateClient(config, RedisClient::new);
return createClient(config, RedisClient::new);
}

@Override
Expand Down
8 changes: 4 additions & 4 deletions java/client/src/main/java/glide/api/RedisClusterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
import response.ResponseOuterClass.Response;

/**
* Async (non-blocking) client for Redis in Cluster mode. Use {@link #CreateClient} to request a
* Async (non-blocking) client for Redis in Cluster mode. Use {@link #createClient} to request a
* client to Redis.
*/
public class RedisClusterClient extends BaseClient
Expand All @@ -86,7 +86,7 @@ public class RedisClusterClient extends BaseClient
TransactionsClusterCommands,
PubSubClusterCommands {

/** A private constructor. Use {@link #CreateClient} to get a client. */
/** A private constructor. Use {@link #createClient} to get a client. */
RedisClusterClient(ClientBuilder builder) {
super(builder);
}
Expand All @@ -97,9 +97,9 @@ public class RedisClusterClient extends BaseClient
* @param config Redis cluster client Configuration.
* @return A Future to connect and return a RedisClusterClient.
*/
public static CompletableFuture<RedisClusterClient> CreateClient(
public static CompletableFuture<RedisClusterClient> createClient(
@NonNull RedisClusterClientConfiguration config) {
return CreateClient(config, RedisClusterClient::new);
return createClient(config, RedisClusterClient::new);
}

@Override
Expand Down
10 changes: 5 additions & 5 deletions java/client/src/test/java/glide/api/RedisClientCreateTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import static glide.api.BaseClient.buildChannelHandler;
import static glide.api.BaseClient.buildMessageHandler;
import static glide.api.RedisClient.CreateClient;
import static glide.api.RedisClient.buildCommandManager;
import static glide.api.RedisClient.buildConnectionManager;
import static glide.api.RedisClient.createClient;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void init() {
mockedClient.when(() -> buildConnectionManager(channelHandler)).thenReturn(connectionManager);
mockedClient.when(() -> buildCommandManager(channelHandler)).thenReturn(commandManager);
mockedClient.when(() -> buildMessageHandler(any())).thenReturn(messageHandler);
mockedClient.when(() -> CreateClient(any(), any())).thenCallRealMethod();
mockedClient.when(() -> createClient(any(), any())).thenCallRealMethod();

var threadPoolResource = ThreadPoolResourceAllocator.getOrCreate(() -> null);
if (threadPoolResource != null) {
Expand All @@ -78,7 +78,7 @@ public void createClient_with_default_config_successfully_returns_RedisClient()
when(connectionManager.connectToRedis(eq(config))).thenReturn(connectToRedisFuture);

// exercise
CompletableFuture<RedisClient> result = CreateClient(config);
CompletableFuture<RedisClient> result = createClient(config);
RedisClient client = result.get();

// verify
Expand All @@ -98,7 +98,7 @@ public void createClient_with_custom_config_successfully_returns_RedisClient() {
when(connectionManager.connectToRedis(eq(config))).thenReturn(connectToRedisFuture);

// exercise
CompletableFuture<RedisClient> result = CreateClient(config);
CompletableFuture<RedisClient> result = createClient(config);
RedisClient client = result.get();

// verify
Expand All @@ -119,7 +119,7 @@ public void createClient_error_on_connection_throws_ExecutionException() {
when(connectionManager.connectToRedis(eq(config))).thenReturn(connectToRedisFuture);

// exercise
CompletableFuture<RedisClient> result = CreateClient(config);
CompletableFuture<RedisClient> result = createClient(config);

ExecutionException executionException = assertThrows(ExecutionException.class, result::get);

Expand Down
3 changes: 1 addition & 2 deletions java/examples/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ repositories {
}

dependencies {
implementation group: 'software.amazon.glide', name: 'glide-for-redis', version: '0.4.3', classifier: osdetector.classifier

implementation project(':client')
implementation 'redis.clients:jedis:4.4.3'
implementation 'io.lettuce:lettuce-core:6.2.6.RELEASE'
implementation 'commons-cli:commons-cli:1.5.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ private static void runGlideExamples() {
.build();

try {
RedisClient client = RedisClient.CreateClient(config).get();
RedisClient client = RedisClient.createClient(config).get();

System.out.println("PING: " + client.ping().get());
System.out.println("PING(found you): " + client.ping("found you").get());
Expand Down
4 changes: 2 additions & 2 deletions java/integTest/src/test/java/glide/ConnectionTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class ConnectionTests {
@SneakyThrows
public void basic_client() {
var regularClient =
RedisClient.CreateClient(
RedisClient.createClient(
RedisClientConfiguration.builder()
.address(
NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build())
Expand All @@ -28,7 +28,7 @@ public void basic_client() {
@SneakyThrows
public void cluster_client() {
var regularClient =
RedisClient.CreateClient(
RedisClient.createClient(
RedisClientConfiguration.builder()
.address(NodeAddress.builder().port(TestConfiguration.CLUSTER_PORTS[0]).build())
.build())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public void standalone_client_with_custom_threadPoolResource() {
}

var regularClient =
RedisClient.CreateClient(
RedisClient.createClient(
RedisClientConfiguration.builder()
.address(
NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build())
Expand Down
6 changes: 3 additions & 3 deletions java/integTest/src/test/java/glide/ErrorHandlingTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public void basic_client_tries_to_connect_to_wrong_address() {
assertThrows(
ExecutionException.class,
() ->
RedisClient.CreateClient(
RedisClient.createClient(
RedisClientConfiguration.builder()
.address(NodeAddress.builder().port(getFreePort()).build())
.build())
Expand All @@ -40,7 +40,7 @@ public void basic_client_tries_to_connect_to_wrong_address() {
@SneakyThrows
public void basic_client_tries_wrong_command() {
try (var regularClient =
RedisClient.CreateClient(
RedisClient.createClient(
RedisClientConfiguration.builder()
.address(
NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build())
Expand All @@ -60,7 +60,7 @@ public void basic_client_tries_wrong_command() {
@SneakyThrows
public void basic_client_tries_wrong_command_arguments() {
try (var regularClient =
RedisClient.CreateClient(
RedisClient.createClient(
RedisClientConfiguration.builder()
.address(
NodeAddress.builder().port(TestConfiguration.STANDALONE_PORTS[0]).build())
Expand Down
8 changes: 4 additions & 4 deletions java/integTest/src/test/java/glide/PubSubTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private <M extends ChannelMode> BaseClient createClientWithSubscriptions(
if (callback.isPresent()) {
subConfigBuilder.callback(callback.get(), context.get());
}
return RedisClient.CreateClient(
return RedisClient.createClient(
commonClientConfig()
.requestTimeout(5000)
.subscriptionConfiguration(subConfigBuilder.build())
Expand All @@ -94,7 +94,7 @@ private <M extends ChannelMode> BaseClient createClientWithSubscriptions(
subConfigBuilder.callback(callback.get(), context.get());
}

return RedisClusterClient.CreateClient(
return RedisClusterClient.createClient(
commonClusterClientConfig()
.requestTimeout(5000)
.subscriptionConfiguration(subConfigBuilder.build())
Expand All @@ -112,9 +112,9 @@ private <M extends ChannelMode> BaseClient createClientWithSubscriptions(
@SneakyThrows
private BaseClient createClient(boolean standalone) {
if (standalone) {
return RedisClient.CreateClient(commonClientConfig().build()).get();
return RedisClient.createClient(commonClientConfig().build()).get();
}
return RedisClusterClient.CreateClient(commonClusterClientConfig().build()).get();
return RedisClusterClient.createClient(commonClusterClientConfig().build()).get();
}

/**
Expand Down
4 changes: 2 additions & 2 deletions java/integTest/src/test/java/glide/SharedClientTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public class SharedClientTests {
@BeforeAll
@SneakyThrows
public static void init() {
standaloneClient = RedisClient.CreateClient(commonClientConfig().build()).get();
standaloneClient = RedisClient.createClient(commonClientConfig().build()).get();
clusterClient =
RedisClusterClient.CreateClient(commonClusterClientConfig().requestTimeout(10000).build())
RedisClusterClient.createClient(commonClusterClientConfig().requestTimeout(10000).build())
.get();

clients = List.of(Arguments.of(standaloneClient), Arguments.of(clusterClient));
Expand Down
Loading
Loading