-
Notifications
You must be signed in to change notification settings - Fork 472
RI-8296 Exact u64 array integer replies (per-command ioredis bigint) #6100
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
Open
VaskoAtanasovRedis
wants to merge
14
commits into
main
Choose a base branch
from
be/RI-8296/ioredis-smart-int-parse
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+832
−255
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
142f586
feat(api): exact u64 array integer replies via per-command ioredis bi…
VaskoAtanasovRedis b83dfc6
feat(api): CLI shows exact u64 for array integer-reply commands [RI-8…
VaskoAtanasovRedis 5bcc1d5
feat(api): Workbench exact u64 for array commands; share the command …
VaskoAtanasovRedis 1078231
test(api): restore the >2^53 ARGREP search integration assertion [RI-…
VaskoAtanasovRedis e6217a9
test(api): prove the (2^53, 2^63) bigint zone for ARLEN + ARSCAN [RI-…
VaskoAtanasovRedis b2c41ac
test(api): lock the array u64 RESP wire encoding in CI [RI-8296]
VaskoAtanasovRedis b1fddc3
test(api): gate the RESP encoding probe off cluster declaratively [RI…
VaskoAtanasovRedis 53ff004
fix(api): keep array u64 exact in key-info and CLI text output [RI-8296]
VaskoAtanasovRedis ee72988
test(api): apply patches in the integration test image [RI-8296]
VaskoAtanasovRedis 443e702
fix(api): show exact u64 array integer replies in CLI and Workbench […
VaskoAtanasovRedis 683e430
fix(api): include AROP in the array u64 bigint opt-in [RI-8296]
VaskoAtanasovRedis 32b9087
test(api): type formatter strategy specs to keep the TS baseline exac…
VaskoAtanasovRedis cdcba22
fix(api): keep the array aggregate endpoint exact for u64 results [RI…
VaskoAtanasovRedis 481ddc7
fix(api): add ARINFO to the array u64 bigint opt-in [RI-8296]
VaskoAtanasovRedis 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 hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| diff --git a/node_modules/ioredis/built/Command.d.ts b/node_modules/ioredis/built/Command.d.ts | ||
| index ea90aa2..ca28897 100644 | ||
| --- a/node_modules/ioredis/built/Command.d.ts | ||
| +++ b/node_modules/ioredis/built/Command.d.ts | ||
| @@ -6,6 +6,7 @@ interface CommandOptions { | ||
| * Set the encoding of the reply, by default buffer will be returned. | ||
| */ | ||
| replyEncoding?: BufferEncoding | null; | ||
| + integerReply?: "number" | "bigint"; | ||
| errorStack?: Error; | ||
| keyPrefix?: string; | ||
| /** | ||
| @@ -75,6 +76,7 @@ export default class Command implements Respondable { | ||
| resolve: (result: any) => void; | ||
| promise: Promise<any>; | ||
| private replyEncoding; | ||
| + integerReply?: "number" | "bigint"; | ||
| private errorStack; | ||
| private bufferMode; | ||
| private callback; | ||
| diff --git a/node_modules/ioredis/built/Command.js b/node_modules/ioredis/built/Command.js | ||
| index 40cd1a6..aad90af 100644 | ||
| --- a/node_modules/ioredis/built/Command.js | ||
| +++ b/node_modules/ioredis/built/Command.js | ||
| @@ -39,6 +39,7 @@ class Command { | ||
| this.isResolved = false; | ||
| this.transformed = false; | ||
| this.replyEncoding = options.replyEncoding; | ||
| + this.integerReply = options.integerReply; | ||
| this.errorStack = options.errorStack; | ||
| this.args = args.flat(); | ||
| this.callback = callback; | ||
| diff --git a/node_modules/ioredis/built/DataHandler.d.ts b/node_modules/ioredis/built/DataHandler.d.ts | ||
| index 93e97d9..24fe877 100644 | ||
| --- a/node_modules/ioredis/built/DataHandler.d.ts | ||
| +++ b/node_modules/ioredis/built/DataHandler.d.ts | ||
| @@ -26,7 +26,11 @@ interface ParserOptions { | ||
| } | ||
| export default class DataHandler { | ||
| private redis; | ||
| + private parser; | ||
| + private stringNumbers; | ||
| constructor(redis: DataHandledable, parserOptions: ParserOptions); | ||
| + private updateIntegerReplyMode; | ||
| + private convertIntegerReply; | ||
| private returnFatalError; | ||
| private returnError; | ||
| private returnReply; | ||
| diff --git a/node_modules/ioredis/built/DataHandler.js b/node_modules/ioredis/built/DataHandler.js | ||
| index 1db1848..f985ed5 100644 | ||
| --- a/node_modules/ioredis/built/DataHandler.js | ||
| +++ b/node_modules/ioredis/built/DataHandler.js | ||
| @@ -8,6 +8,7 @@ const debug = (0, utils_1.Debug)("dataHandler"); | ||
| class DataHandler { | ||
| constructor(redis, parserOptions) { | ||
| this.redis = redis; | ||
| + this.stringNumbers = parserOptions.stringNumbers; | ||
| const parser = new RedisParser({ | ||
| stringNumbers: parserOptions.stringNumbers, | ||
| returnBuffers: true, | ||
| @@ -21,10 +22,27 @@ class DataHandler { | ||
| this.returnReply(reply); | ||
| }, | ||
| }); | ||
| + this.parser = parser; | ||
| redis.stream.on("data", (data) => { | ||
| + this.updateIntegerReplyMode(); | ||
| parser.execute(data); | ||
| }); | ||
| } | ||
| + updateIntegerReplyMode() { | ||
| + var _a, _b; | ||
| + const item = (_a = this.redis.commandQueue) === null || _a === void 0 ? void 0 : _a.peekFront(); | ||
| + const integerReply = (_b = item === null || item === void 0 ? void 0 : item.command) === null || _b === void 0 ? void 0 : _b.integerReply; | ||
| + this.parser.setStringNumbers(this.stringNumbers || integerReply === "bigint"); | ||
|
VaskoAtanasovRedis marked this conversation as resolved.
VaskoAtanasovRedis marked this conversation as resolved.
|
||
| + } | ||
| + convertIntegerReply(reply) { | ||
| + if (typeof reply === "string") { | ||
| + return BigInt(reply); | ||
| + } | ||
| + if (Array.isArray(reply)) { | ||
| + return reply.map((item) => this.convertIntegerReply(item)); | ||
| + } | ||
| + return reply; | ||
| + } | ||
| returnFatalError(err) { | ||
| err.message += ". Please report this."; | ||
| this.redis.recoverFromFatalError(err, err, { offlineQueue: false }); | ||
| @@ -34,6 +52,7 @@ class DataHandler { | ||
| if (!item) { | ||
| return; | ||
| } | ||
| + this.updateIntegerReplyMode(); | ||
| err.command = { | ||
| name: item.command.name, | ||
| args: item.command.args, | ||
| @@ -51,6 +70,10 @@ class DataHandler { | ||
| if (!item) { | ||
| return; | ||
| } | ||
| + this.updateIntegerReplyMode(); | ||
| + if (item.command.integerReply === "bigint") { | ||
| + reply = this.convertIntegerReply(reply); | ||
| + } | ||
|
cursor[bot] marked this conversation as resolved.
|
||
| if (Command_1.default.checkFlag("ENTER_SUBSCRIBER_MODE", item.command.name)) { | ||
| this.redis.condition.subscriber = new SubscriptionSet_1.default(); | ||
| this.redis.condition.subscriber.add(item.command.name, reply[1].toString()); | ||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Kudos 🍕