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

added lua scripts support in node. #775

Merged
merged 1 commit into from
Jan 11, 2024
Merged

added lua scripts support in node. #775

merged 1 commit into from
Jan 11, 2024

Conversation

adanWattad
Copy link
Contributor

Issue #, if available:

Description of changes:

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

@adanWattad adanWattad requested a review from a team as a code owner January 10, 2024 12:00
@adanWattad adanWattad force-pushed the node/scripts branch 2 times, most recently from ff7e60e to ea6cb39 Compare January 10, 2024 12:07
Copy link
Contributor

@shachlanAmazon shachlanAmazon left a comment

Choose a reason for hiding this comment

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

round

node/index.ts Outdated Show resolved Hide resolved
node/src/Script.ts Outdated Show resolved Hide resolved
/**
* @internal
*/
protected createScriptWritePromise<T>(
Copy link
Contributor

Choose a reason for hiding this comment

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

why not use createWritePromise and just pass message to the function?

@@ -888,6 +935,16 @@ export class BaseClient {
return this.createWritePromise(createTTL(key));
}

/** Invoke the given script with its keys and arguments.
Copy link
Contributor

Choose a reason for hiding this comment

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

please fully flesh out the comment - what does this do?
remember, the user expects us to have something that is mappable to Redis commands. You need to explain, at least roughly, what happens internally.

node/tests/SharedTests.ts Show resolved Hide resolved
@@ -297,8 +309,9 @@ export class BaseClient {
* @internal
*/
protected createWritePromise<T>(
command: redis_request.Command | redis_request.Command[],
route?: redis_request.Routes
command?: redis_request.Command | redis_request.Command[],
Copy link
Contributor

Choose a reason for hiding this comment

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

the way you implemented this, this function can be called without any argument. That doesn't make sense to me.
why not make command be either redis_request.Command | redis_request.Command[] | redis_request.RedisRequest?
Or, wouldn't it make even more sense to pass redis_request.ScriptInvocation instead of redis_request.RedisRequest, and skip the repetition of the callback index handling?

@@ -888,6 +913,40 @@ export class BaseClient {
return this.createWritePromise(createTTL(key));
}

/** Invokes a Lua script with its keys and arguments.
* This method simplifies the process of invoking scripts on a Redis server by using an object that represents a Lua script.
* The Script object is immutable and can be shared.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does this line belong here? shouldn't it be on the script object?


expect(
await client.invokeScript(script, { keys: [key2] })
).toEqual("bar");
Copy link
Contributor

Choose a reason for hiding this comment

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

if you give both keys the same value, how do you know that you actually got the value from the second key?

@adanWattad adanWattad merged commit 9d6010d into main Jan 11, 2024
6 checks passed
@adanWattad adanWattad deleted the node/scripts branch January 11, 2024 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants