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

Lua binary support #1729

Merged
merged 16 commits into from
Jul 2, 2024
Merged

Lua binary support #1729

merged 16 commits into from
Jul 2, 2024

Conversation

yulazariy
Copy link
Contributor

@yulazariy yulazariy commented Jun 30, 2024

Issue #, if available:

Description of changes:
Add support for GlideString for Lua scripts

glide-core changes

  1. Change InvocationScript message to use bytes instead of strings
  2. Fix socket_listener and scripts_container to use byte array for storing scripts
  3. update redis commands load, eval and the internal invoke_script to use byte array
  4. small refactor in scripts_container

java changes

  1. Add new script options class for glide string script parameters
  2. Fix storeScript ffi according to new message to get bytes array
  3. Add new handler handleBinaryObjectOrNullResponse
  4. Add Script constructor to get GlideString for script argument
  5. Add Script class new member binarySafeOutput to be able to diffrintiate between output types on invocation

python changes

  1. Change script constructor for to accept PyAny. No overloads in rust for the constructor and python don't support templates
  2. Change _execute_script to convert keys, args to bytes

node changes

  1. Change Script consturctor to accept string or uint8array
  2. Change ScriptOptions to have args,keys of string or uint8array

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

Yulazari and others added 2 commits June 30, 2024 15:24
glide-core changes

1. Change InvocationScript message to use bytes instead of strings
2. Fix socket_listener and scripts_container to use byte array for storing scripts
3. update redis commands load, eval and the internal invoke_script to use byte array
4. small refactor in scripts_container

java changes

1. Add new script options class for glide string script parameters
2. Fix storeScript ffi according to new message to get bytes array
3. Add new handler handleBinaryObjectOrNullResponse
4. Add Script constructore to get GlideString for script argument
5. Add Script class new member binarySafeOutput to be able to diffrintiate between output types on invocation
@yulazariy yulazariy requested a review from a team as a code owner June 30, 2024 12:44
java/client/src/main/java/glide/api/models/Script.java Outdated Show resolved Hide resolved
Copy link
Collaborator

Choose a reason for hiding this comment

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

Replace existing options without introducing new classes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not fully understand

Copy link
Collaborator

Choose a reason for hiding this comment

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

Patch existing class to store GlideString instead of String

yulazariy and others added 9 commits July 1, 2024 09:40
1. Change script constructor for to accept PyAny. No noverloads in rust for the constructor and python don't support templates
2. Chage _execute_script to convert keys,args to bytes
1. Change Script consturctor to accept string or uint8array
2. Change ScriptOptions to have args,keys of string or uint8array
java/client/src/main/java/glide/api/BaseClient.java Outdated Show resolved Hide resolved
java/client/src/main/java/glide/api/BaseClient.java Outdated Show resolved Hide resolved
java/client/src/main/java/glide/api/BaseClient.java Outdated Show resolved Hide resolved
java/client/src/main/java/glide/api/BaseClient.java Outdated Show resolved Hide resolved
java/client/src/main/java/glide/api/BaseClient.java Outdated Show resolved Hide resolved
java/client/src/main/java/glide/api/models/Script.java Outdated Show resolved Hide resolved
node/src/BaseClient.ts Outdated Show resolved Hide resolved
node/src/BaseClient.ts Outdated Show resolved Hide resolved
Comment on lines 4974 to 4975
keys (Union[str, bytes]): The keys that are used in the script.
args (Union[str, bytes]): The arguments for the script.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
keys (Union[str, bytes]): The keys that are used in the script.
args (Union[str, bytes]): The arguments for the script.
keys (List[Union[str, bytes]]): The keys that are used in the script.
args (List[Union[str, bytes]]): The arguments for the script.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed!

@@ -658,7 +660,8 @@ CompletableFuture<Boolean> pexpireAt(
* @return a value that depends on the script that was executed.
* @example
* <pre>{@code
* try(Script luaScript = new Script("return { KEYS[1], ARGV[1] }")) {
* try(Script luaScript = new Script("return { KEYS[1], ARGV[1] }", true)) {
* luaScript.setBinarySafeOutput(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* luaScript.setBinarySafeOutput(true);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -635,7 +636,8 @@ CompletableFuture<Boolean> pexpireAt(
* @return a value that depends on the script that was executed.
* @example
* <pre>{@code
* try(Script luaScript = new Script("return 'Hello'")) {
* try(Script luaScript = new Script("return 'Hello'", true)) {
* luaScript.setBinarySafeOutput(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
* luaScript.setBinarySafeOutput(true);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@yulazariy yulazariy merged commit 90e5c88 into valkey-io:main Jul 2, 2024
68 checks passed
cyip10 pushed a commit to Bit-Quill/valkey-glide that referenced this pull request Jul 16, 2024
* Add support for GlideString for Lua scripts

glide-core changes

1. Change InvocationScript message to use bytes instead of strings
2. Fix socket_listener and scripts_container to use byte array for storing scripts
3. update redis commands load, eval and the internal invoke_script to use byte array
4. small refactor in scripts_container

java changes

1. Add new script options class for glide string script parameters
2. Fix storeScript ffi according to new message to get bytes array
3. Add new handler handleBinaryObjectOrNullResponse
4. Add Script constructore to get GlideString for script argument
5. Add Script class new member binarySafeOutput to be able to diffrintiate between output types on invocation

python changes

1. Change script constructor for to accept PyAny. No noverloads in rust for the constructor and python don't support templates
2. Chage _execute_script to convert keys,args to bytes

node changes

1. Change Script consturctor to accept string or uint8array
2. Change ScriptOptions to have args,keys of string or uint8array

---------

Co-authored-by: Yulazari <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants