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 FUNCTION LIST command. #1452

Merged
merged 15 commits into from
Jun 5, 2024

Conversation

Yury-Fridlyand
Copy link
Collaborator

@Yury-Fridlyand Yury-Fridlyand commented May 23, 2024

Issue #, if available:
N/A

Description of changes:
https://redis.io/docs/latest/commands/function-list/

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

Some highlights in this PR:

  • data conversion (value_conversion.rs)
  • new functions for standalone and cluster clients' interfaces (ScriptingAndFunctions*Commands.java)
  • implementations for both client types (RedisClient.java & RedisClusterClient.java)
  • response handling (BaseClient.java)
  • transaction update (BaseTransaction.java)
  • new options (not for user use, but to avoid client classes being polluted by them, moved to a another place - FunctionListOptions.java)
  • UT (java/client/src/test/...)
  • transaction IT (TransactionTestUtilities.java)
  • command IT (CommandTests.java)
  • IT tools (TestUtilities.java)

Some details on how response conversion works:

image

Signed-off-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Yury-Fridlyand <[email protected]>
* Add `FUNCTION LIST` command.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Tests for the God of Tests.

Signed-off-by: Yury-Fridlyand <[email protected]>

* I HATE YOU SPOTLESS

Signed-off-by: Yury-Fridlyand <[email protected]>

* Ruuuuuuuuuuuuuuuuuust

Signed-off-by: Yury-Fridlyand <[email protected]>

* Add `@since`.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Update examples.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Clean up value conversion code.

Signed-off-by: Yury-Fridlyand <[email protected]>

* Address PR comments.

Signed-off-by: Yury-Fridlyand <[email protected]>

---------

Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand added the java issues and fixes related to the java client label May 23, 2024
@Yury-Fridlyand Yury-Fridlyand requested a review from a team as a code owner May 23, 2024 19:53
glide-core/src/client/value_conversion.rs Outdated Show resolved Hide resolved
glide-core/src/client/value_conversion.rs Outdated Show resolved Hide resolved
glide-core/src/client/value_conversion.rs Outdated Show resolved Hide resolved

/**
* Returns information about the functions and libraries.<br>
* The command will be routed to all primary nodes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Just wanted to double check, are we sure this is correct? Unlike FUNCTION FLUSH and FUNCTION LOAD, which have an ALL_SHARDS request policy (see here), FUNCTION LIST does not have any request policy (see here)

On a related note, unlike FUNCTION LOAD and FUNCTION FLUSH, this command is not in cluster_routing.rs, I'm assuming we'll have to add it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh right, going to add it

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

please close this

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated & closed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we still need to update redis-rs#cluster_routing.rs to map this command to RANDOM, since the default is FirstKey

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Reopened

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

image

Signed-off-by: Yury-Fridlyand <[email protected]>

Co-authored-by: Aaron <[email protected]>
glide-core/src/client/value_conversion.rs Outdated Show resolved Hide resolved
@@ -5,7 +5,7 @@ use redis::{
cluster_routing::Routable, from_owned_redis_value, Cmd, ErrorKind, RedisResult, Value,
};

#[derive(Clone, Copy)]
#[derive(Clone, Copy, Debug)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is required for debug logging. I decided to keep it.

3) "engine"
4) "LUA"
5) "functions"
6) 1) 1) "name"
Copy link
Collaborator

Choose a reason for hiding this comment

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

is this a set?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

flags is a set


/**
* Returns information about the functions and libraries.<br>
* The command will be routed to all primary nodes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

please close this

Copy link
Collaborator

@jonathanl-bq jonathanl-bq left a comment

Choose a reason for hiding this comment

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

Approved with some minor comments on the Rust side, though, I skimmed through the Java side briefly too.

glide-core/src/client/value_conversion.rs Outdated Show resolved Hide resolved
}
}

/// Similar to [`convert_array_to_map`], but converts a map to a map.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Kind of confusingly worded. I think this is a little more clear:

Suggested change
/// Similar to [`convert_array_to_map`], but converts a map to a map.
/// Similar to [`convert_array_to_map`], but converts an array of value pairs to a map.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, but saying "map to a map" sounds like you're just running the identity function (which you are not). What does this actually do?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It converts keys and values inside the map. So input is a map and output is a map too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, I feel like the comment could describe it as such. Otherwise, the function looks like it just takes a map and returns it, based on the description. That being said, if you really want to, you can leave the comment as is. I don't think it'll matter much in the long run for such a minor documentation nit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated, thank you.


/**
* Returns information about the functions and libraries.<br>
* The command will be routed to all primary nodes.
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we still need to update redis-rs#cluster_routing.rs to map this command to RANDOM, since the default is FirstKey

Copy link
Collaborator

@aaron-congo aaron-congo left a comment

Choose a reason for hiding this comment

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

LGTM but we will need to merge the change to redis-rs first

Signed-off-by: Yury-Fridlyand <[email protected]>
Copy link
Collaborator

@barshaul barshaul left a comment

Choose a reason for hiding this comment

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

This PR is too large to be properly reviewed, and there are some parts which can be easily moved to different PRs - for example the value conversion logic.
You can have PRs that are being rebased over others, but we need to have smaller PRs in order to make sure we're not missing anything.

Yury-Fridlyand added a commit to Bit-Quill/valkey-glide that referenced this pull request May 29, 2024
@Yury-Fridlyand
Copy link
Collaborator Author

This PR is too large to be properly reviewed, and there are some parts which can be easily moved to different PRs - for example the value conversion logic. You can have PRs that are being rebased over others, but we need to have smaller PRs in order to make sure we're not missing anything.

Please see #1489

@Yury-Fridlyand
Copy link
Collaborator Author

Suspended: waiting for #1489 and for amazon-contributing/redis-rs#148

@Yury-Fridlyand Yury-Fridlyand marked this pull request as draft May 30, 2024 00:53
@Yury-Fridlyand Yury-Fridlyand marked this pull request as ready for review June 5, 2024 02:10
Signed-off-by: Yury-Fridlyand <[email protected]>
@Yury-Fridlyand Yury-Fridlyand dismissed barshaul’s stale review June 5, 2024 02:25

Review addressed in #1489 which is already merged

@Yury-Fridlyand Yury-Fridlyand merged commit 200d68f into valkey-io:main Jun 5, 2024
46 checks passed
@Yury-Fridlyand Yury-Fridlyand deleted the java/integ_yuryf_flist branch June 5, 2024 02:26
yipin-chen pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 7, 2024
* Add `FUNCTION LIST` command. (#277)

Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: Aaron <[email protected]>
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jun 24, 2024
* Add `FUNCTION LIST` command. (#277)

Signed-off-by: Yury-Fridlyand <[email protected]>
Co-authored-by: Aaron <[email protected]>
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.

5 participants