-
Notifications
You must be signed in to change notification settings - Fork 68
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: Add PING command #914
Java: Add PING command #914
Conversation
throw new RedisException( | ||
"Unexpected return type from Redis: got " + className + " expected Map"); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should make sections/regions - for handlers, for commands for all rest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure - but let's leave this for a future update. This will be useful when we have more than 3 commands.
java/client/src/test/java/glide/api/RedisClusterClientTest.java
Outdated
Show resolved
Hide resolved
java/client/src/test/java/glide/api/RedisClusterClientTest.java
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Override | ||
public CompletableFuture<String> ping(String str) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw that you added @nonnull annotations for cluster why not here?
java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java
Show resolved
Hide resolved
java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java
Show resolved
Hide resolved
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
177857c
to
0b2aa76
Compare
* @return Response as a <code>String</code> | ||
* @throws RedisException if there's a type mismatch | ||
*/ | ||
protected String handleStringResponse(Response response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not necessarily for this PR - this has a very similar structure to the handleArrayResponse.
Consider making a generic function with some refinement of this imaginary code:
protected T handleResponse<T>(Response response) {
Object value = handleObjectResponse(response);
if (value instanceof T || value == null) {
return (T) value;
}
throw new RedisException(
"Unexpected return type from Redis: got "
+ value.getClass().getSimpleName()
+ " expected " + T.getType());
}
```
of course, `T.getType()` isn't really possible and this doesn't handle primitives well, but I believe this is possible, and will remove a lot of glue code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea. I've updated to include the generic function - this will reduce code duplication.
return CreateClient(config, RedisClient::new); | ||
} | ||
|
||
@Override | ||
public CompletableFuture<Object> customCommand(String[] args) { | ||
public CompletableFuture<Object> customCommand(@NonNull String[] args) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct me if I'm wrong, but @NonNull
applies here to the array - the strings themselves might still be null?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct... and that would cause a protobuf builder error (NullPointerException).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so how would you solve this?
java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java
Show resolved
Hide resolved
@@ -25,12 +26,13 @@ protected RedisClient(ConnectionManager connectionManager, CommandManager comman | |||
* @param config Redis client Configuration | |||
* @return A Future to connect and return a RedisClient | |||
*/ | |||
public static CompletableFuture<RedisClient> CreateClient(RedisClientConfiguration config) { | |||
public static CompletableFuture<RedisClient> CreateClient( | |||
@NonNull RedisClientConfiguration config) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding for consistency across all methods. @nonnull will return a NullPointerException
if the argument is not defined.
java/client/src/main/java/glide/api/commands/ConnectionManagementClusterCommands.java
Show resolved
Hide resolved
Signed-off-by: Andrew Carbonetto <[email protected]>
*/ | ||
private <T> T handleRedisResponse(Class classType, boolean isNullable, Response response) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private <T> T handleRedisResponse(Class classType, boolean isNullable, Response response) { | |
protected <T> T handleRedisResponse(Class<T> classType, boolean isNullable, Response response) throws RedisException { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @shachlanAmazon for the idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not private?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated in 2cbf558
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
Issue #, if available:
This PR is dependent to: #917
Description of changes:
This PR adds get/set/ping/info calls to the standalone, and cluster-mode:
Examples:
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.