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 - Add custom command interface; and BaseCommands #798

Closed

Conversation

acarbonetto
Copy link
Contributor

Issue #, if available:

API layer for: #589

Description of changes:

In this PR, we are adding basic infrastructure for commands, including the custom command that takes any command type and set of arguments, and returns an Object.

The Redis value_from_pointer is called to convert the value form a Rust objects to Java objects, so the FFI calls for complex objects are necessary for converting from complex objects.

Example:

CompletableFuture<RedisClient> createClientRequest = RedisClient.CreateClient(config); 

try (RedisClient client = createClientRequest.get()) 
{
      Object customGetMyKey = client.customCommand(new String[]{"get", "myKey"}).get();
      System.out.println("Glide CUSTOM_COMMAND(get, myKey): " + customGetMyKey);

      Object customGetInvalid = client.customCommand(new String[]{"get", "invalid"}).get();
      System.out.println("Glide CUSTOM_COMMAND(get, invalid): " + customGetInvalid);

} catch (ExecutionException executionException) {
    if (executionException.getCause() instanceOf RedisException) {
         // try again
  }
}

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@acarbonetto acarbonetto requested a review from a team as a code owner January 16, 2024 17:54
@acarbonetto acarbonetto changed the title Java/integ acarbo api base commands Java - Add custom command interface; and BaseCommands Jan 16, 2024
@acarbonetto acarbonetto added the java issues and fixes related to the java client label Jan 16, 2024
return BaseCommands.applyBaseCommandResponseResolver().apply(response);
}

public static List<Object> handleTransactionResponse(Response response) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the interface is public to the use, this will also be public to the user. Why do we want to expose this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question. I can hide this from the user, like RedisValueResolver::valueFromPointer is not being exposed.
This also applies to BaseCommandResponseResolver class?

Signed-off-by: Andrew Carbonetto <[email protected]>
* Add base command; add custom command

---------

Signed-off-by: Andrew Carbonetto <[email protected]>
Signed-off-by: Andrew Carbonetto <[email protected]>
@acarbonetto acarbonetto force-pushed the java/integ_acarbo_api_baseCommands branch from 1003fd5 to 0ce8962 Compare January 16, 2024 22:38
@acarbonetto acarbonetto self-assigned this Jan 17, 2024
@acarbonetto acarbonetto deleted the java/integ_acarbo_api_baseCommands branch February 23, 2024 17:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
java issues and fixes related to the java client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants