-
Notifications
You must be signed in to change notification settings - Fork 71
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
Node: Handle commands with binary output in transaction #2133
Closed
Yury-Fridlyand
wants to merge
7
commits into
valkey-io:main
from
Bit-Quill:node/yuryf-transaction-bin
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
438e03e
Add `FUNCTION DUMP` and `FUNCTION RESTORE` commands.
Yury-Fridlyand e252c7d
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Yury-Fridlyand 1eb3602
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Yury-Fridlyand 058b267
Handle commands with binary output in transaction.
Yury-Fridlyand ef8f04f
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Yury-Fridlyand e1c1312
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Yury-Fridlyand 8ae26eb
Signed-off-by: Yury-Fridlyand <yury.fridlyand@improving.com>
Yury-Fridlyand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -367,37 +367,57 @@ export class GlideClusterClient extends BaseClient { | |||||
}); | ||||||
} | ||||||
|
||||||
/** Execute a transaction by processing the queued commands. | ||||||
* See https://redis.io/topics/Transactions/ for details on Redis Transactions. | ||||||
/** | ||||||
* Execute a transaction by processing the queued commands. | ||||||
* | ||||||
* @see {@link https://valkey.io/topics/transactions/} for details on Valkey Transactions. | ||||||
* | ||||||
* @param transaction - A ClusterTransaction object containing a list of commands to be executed. | ||||||
* @param route - If `route` is not provided, the transaction will be routed to the slot owner of the first key found in the transaction. | ||||||
* If no key is found, the command will be sent to a random node. | ||||||
* If `route` is provided, the client will route the command to the nodes defined by `route`. | ||||||
* @param transaction - A {@link ClusterTransaction} object containing a list of commands to be executed. | ||||||
* @param route - (Optional) If `route` is not provided, the transaction will be routed to the slot owner of the first key found in the transaction. | ||||||
* If no key is found, the command will be sent to a random node. | ||||||
* If `route` is provided, the client will route the command to the nodes defined by `route`. | ||||||
* @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 | ||||||
* or {@link Decoder.Bytes} if there are commands which produce binary output. | ||||||
* @returns A list of results corresponding to the execution of each command in the transaction. | ||||||
* If a command returns a value, it will be included in the list. If a command doesn't return a value, | ||||||
* the list entry will be null. | ||||||
* If the transaction failed due to a WATCH command, `exec` will return `null`. | ||||||
* If a command returns a value, it will be included in the list. If a command doesn't return a value, | ||||||
* the list entry will be `null`. | ||||||
* If the transaction failed due to a `WATCH` command, `exec` will return `null`. | ||||||
*/ | ||||||
public exec( | ||||||
public async exec( | ||||||
transaction: ClusterTransaction, | ||||||
options?: { | ||||||
route?: SingleNodeRoute; | ||||||
decoder?: Decoder; | ||||||
}, | ||||||
): Promise<ReturnType[] | null> { | ||||||
if ( | ||||||
options && | ||||||
options?.decoder != Decoder.Bytes && | ||||||
transaction.requiresBinaryDecorer | ||||||
) { | ||||||
throw new RequestError( | ||||||
"Transaction has a command which requres `Decoder.Bytes`.", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe:
|
||||||
); | ||||||
} | ||||||
|
||||||
const decoder = | ||||||
options?.decoder ?? | ||||||
(transaction.requiresBinaryDecorer | ||||||
? Decoder.Bytes | ||||||
: this.defaultDecoder); | ||||||
return this.createWritePromise<ReturnType[] | null>( | ||||||
transaction.commands, | ||||||
{ | ||||||
route: toProtobufRoute(options?.route), | ||||||
decoder: options?.decoder, | ||||||
decoder: decoder, | ||||||
}, | ||||||
).then((result: ReturnType[] | null) => { | ||||||
return this.processResultWithSetCommands( | ||||||
).then((result) => | ||||||
this.processResultWithSetCommands( | ||||||
result, | ||||||
transaction.setCommandsIndexes, | ||||||
); | ||||||
}); | ||||||
), | ||||||
); | ||||||
} | ||||||
|
||||||
/** Ping the Redis server. | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.