Skip to content

Add SCRIPT SHOW command#2171

Merged
shohamazon merged 8 commits intovalkey-io:mainfrom
shohamazon:script-show
Sep 12, 2024
Merged

Add SCRIPT SHOW command#2171
shohamazon merged 8 commits intovalkey-io:mainfrom
shohamazon:script-show

Conversation

@shohamazon
Copy link
Collaborator

@shohamazon shohamazon commented Aug 20, 2024

TODO:

  • add default routing to random node
  • add to is_readonly_cmd

@shohamazon shohamazon requested a review from a team as a code owner August 20, 2024 17:03
@shohamazon shohamazon added python 🐍 Python wrapper node 🐢 Node.js wrapper java ☕ issues and fixes related to the java client labels Aug 20, 2024
Copy link

@Yury-Fridlyand Yury-Fridlyand left a comment

Choose a reason for hiding this comment

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

Changelog? Transaction?

@Override
public CompletableFuture<String> scriptShow(@NonNull String sha1) {
return commandManager.submitNewCommand(
ScriptShow, new String[] {sha1}, this::handleStringResponse);

Choose a reason for hiding this comment

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

Does it return null if no script found? If yes, use another handler

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no it panics

Choose a reason for hiding this comment

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

Oh right valkey-io/valkey#617
Should be added to the doc in all clients

@ParameterizedTest(autoCloseArguments = false)
@MethodSource("getClients")
public void scriptShow_test(BaseClient client) {
assumeTrue(SERVER_VERSION.isGreaterThanOrEqualTo("7.9.0"));

Choose a reason for hiding this comment

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

Why 7.9? Use 8.0

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

its release candidate so it would be changed when they will actually release it #2168

Choose a reason for hiding this comment

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

You can put version check 8.0 and tests start run on this version once everything implemented

Copy link
Contributor

Choose a reason for hiding this comment

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

or make it a constant we just need to update the constant when it's released.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have already added this before so it wont make any difference now 🙁

* See {@link https://valkey.io/commands/script-show} for more details.
*
* @param sha1 - The SHA1 digest of the script.
* @param decoder - (Optional) {@link Decoder} type which defines how to handle the response. If not set, the default decoder from the client config will be used.

Choose a reason for hiding this comment

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

Suggested change
* @param decoder - (Optional) {@link Decoder} type which defines how to handle the response. If not set, the default decoder from the client config will be used.
* @param decoder - (Optional) {@link Decoder} type which defines how to handle the response.
* If not set, the {@link BaseClientConfiguration.defaultDecoder|default decoder} will be used.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I copied it from another command

Choose a reason for hiding this comment

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

We're going to update it in all commands

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

ohh okay

Choose a reason for hiding this comment

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

Actually we decided to use DecoderOption, see #2234

@asafpamzn asafpamzn mentioned this pull request Aug 25, 2024
7 tasks
@shohamazon
Copy link
Collaborator Author

Changelog? Transaction?

will add changelog, we dont have scripts in transaction

assertEquals(payload, response.get());
}

/*@SneakyThrows
Copy link
Contributor

Choose a reason for hiding this comment

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

can you throw in a comment to explain why this was removed/commented out?

Copy link
Contributor

Choose a reason for hiding this comment

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

Enabling this test causes the scan_with_option tests to fail CI.  
TODO:  fix the scan_with_options tests and remove dependency on dynamic libraries

@ParameterizedTest(autoCloseArguments = false)
@MethodSource("getClients")
public void scriptShow_test(BaseClient client) {
assumeTrue(SERVER_VERSION.isGreaterThanOrEqualTo("7.9.0"));
Copy link
Contributor

Choose a reason for hiding this comment

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

or make it a constant we just need to update the constant when it's released.

* ```
*/
public async scriptShow(
sha1: GlideString,
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: is there a reason why we don't pass the Script object and internally we can call script.getHash()?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

same as script exists, kill ect...

Copy link
Contributor

Choose a reason for hiding this comment

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

well... the comment could apply to any of these commands.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have no idea 🙉

public void scriptShow_returns_script_source_glidestring() {
// setup
GlideString scriptSource = gs("return { KEYS[1], ARGV[1] }");
Script script = mock(Script.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove
Your unit tests are probably failing because of this mock. And script is not needed anywhere.

shohamazon and others added 5 commits September 12, 2024 07:32
Signed-off-by: Shoham Elias <[email protected]>
Co-authored-by: Yury-Fridlyand <[email protected]>
Signed-off-by: Shoham Elias <[email protected]>
Signed-off-by: Shoham Elias <[email protected]>
Signed-off-by: Shoham Elias <[email protected]>
Signed-off-by: Shoham Elias <[email protected]>
Signed-off-by: Shoham Elias <[email protected]>
@shohamazon shohamazon force-pushed the script-show branch 2 times, most recently from 8929f01 to af8f6ec Compare September 12, 2024 09:20
Signed-off-by: Shoham Elias <[email protected]>
@shohamazon shohamazon merged commit 7d5de72 into valkey-io:main Sep 12, 2024
@shohamazon shohamazon deleted the script-show branch September 12, 2024 10:05
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 node 🐢 Node.js wrapper python 🐍 Python wrapper Release blocker 🛡️ Can't release without.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants