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

New RESP2 parser #1899

Merged
merged 34 commits into from
Apr 25, 2022
Merged

New RESP2 parser #1899

merged 34 commits into from
Apr 25, 2022

Conversation

leibale
Copy link
Collaborator

@leibale leibale commented Feb 7, 2022

No description provided.

@leibale leibale requested a review from chayim February 7, 2022 20:10
@lgtm-com
Copy link

lgtm-com bot commented Feb 7, 2022

This pull request introduces 2 alerts when merging b0b2464 into 9f0f7f5 - view on LGTM.com

new alerts:

  • 2 for Unused variable, import, function or class

@leibale leibale changed the title A new RESP2 parser New RESP2 parser Feb 7, 2022
@codecov-commenter
Copy link

codecov-commenter commented Feb 9, 2022

Codecov Report

Merging #1899 (c16c801) into master (b1a0b48) will increase coverage by 0.08%.
The diff coverage is 96.46%.

❗ Current head c16c801 differs from pull request most recent head 6b2de37. Consider uploading reports for the commit 6b2de37 to get more accurate results

@@            Coverage Diff             @@
##           master    #1899      +/-   ##
==========================================
+ Coverage   95.37%   95.46%   +0.08%     
==========================================
  Files         392      396       +4     
  Lines        3546     3682     +136     
  Branches      417      442      +25     
==========================================
+ Hits         3382     3515     +133     
- Misses         86       87       +1     
- Partials       78       80       +2     
Impacted Files Coverage Δ
packages/client/lib/commander.ts 91.42% <50.00%> (-4.94%) ⬇️
packages/client/lib/client/index.ts 87.38% <83.33%> (ø)
packages/client/lib/client/commands-queue.ts 81.29% <86.11%> (-0.59%) ⬇️
...ckages/client/lib/client/RESP2/composers/buffer.ts 100.00% <100.00%> (ø)
...ckages/client/lib/client/RESP2/composers/string.ts 100.00% <100.00%> (ø)
packages/client/lib/client/RESP2/decoder.ts 100.00% <100.00%> (ø)
packages/client/lib/client/RESP2/encoder.ts 100.00% <100.00%> (ø)
packages/client/lib/client/multi-command.ts 85.41% <100.00%> (ø)
packages/client/lib/client/socket.ts 78.94% <100.00%> (-0.22%) ⬇️
packages/client/lib/errors.ts 100.00% <100.00%> (ø)
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b1a0b48...6b2de37. Read the comment docs.


it('should compose two buffers', () => {
composer.write(Buffer.from([0]));
assert.deepEqual(
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Are deepequal comparisons expensive in node? They are in Go.

#findCRLF(chunk: Buffer): number {
for (let i = this.#cursor; i < chunk.length; i++) {
if (chunk[i] === CR) {
return i;
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be a style difference. In python I'm more likely to do something like:

f = -1
for thing ... <my loop>:
    if things match:
        f = thing
        break
return f

I find it makes it easier to read functions when you're not looking for multiple returns


#arrayItemType?: Types;

#parseArray(chunk: Buffer, arraysToKeep = 0): ArrayReply | undefined {
Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this feels ugly - you're right.
It also looks right.

@lgtm-com
Copy link

lgtm-com bot commented Feb 10, 2022

This pull request introduces 1 alert when merging 1331698 into 11b0c06 - view on LGTM.com

new alerts:

  • 1 for Unused variable, import, function or class

Comment on lines +41 to +45
function generateTests({
toWrite,
returnStringsAsBuffers,
replies
}: TestsOptions): void {
Copy link

Choose a reason for hiding this comment

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

No commenting

Comment on lines 121 to 130
} catch (err) {
this.#socket.destroy();
this.#socket = undefined;

throw err;
if (err instanceof AuthError) {
this.#isOpen = false;
}

if (!this.#isOpen) return;
throw err;
}
Copy link

Choose a reason for hiding this comment

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

should we do console.error(err)

@leibale leibale added this to To do in v4.1 Apr 4, 2022
@leibale leibale merged commit 23b6513 into redis:master Apr 25, 2022
@leibale leibale deleted the parser branch April 25, 2022 12:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
v4.1
To do
Development

Successfully merging this pull request may close these issues.

None yet

4 participants