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

fix: xreadgroup command keys parsing #31

Merged
merged 3 commits into from
May 10, 2019
Merged

fix: xreadgroup command keys parsing #31

merged 3 commits into from
May 10, 2019

Conversation

borsucok
Copy link
Contributor

@borsucok borsucok commented Mar 1, 2019

No description provided.

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

Thanks a lot for your PR but it does not seem to be exactly correct. The keys are all arguments behind STREAMS until the ID part. From the documentation itself it's not clear if the string ID will be present or not (looking at the example, it's not but that is against the way how the rest of the documentation normally works. I'll have to verify that against Redis itself. If it's not clear what part the "ID" is, it'll be difficult to actually name the keys properly).

Please also check for the linter error. Thanks.

@BridgeAR
Copy link
Member

BridgeAR commented May 8, 2019

Seems like the key indices are in pseudo code: (position after STREAMS) ... (arguments.length - (position after STREAMS)) / 2).

add xread keys parsing
add tests
@borsucok
Copy link
Contributor Author

@BridgeAR thank you for your help. I rewrite it and add some tests. I also add xread command features (basicly the same as xreadgroup)

if (args[i].toUpperCase() === 'STREAMS') {
for (var j = i + 1; j < (args.length - 1); j++) {
if (String(args[i]).toUpperCase() === 'STREAMS') {
for (j = i + 1; j <= i + ((args.length - 1 - i) / 2); j++) {

Choose a reason for hiding this comment

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

Thanks for this!

nitpicky microoptimisation -- for xread you need to start at 0, but for xreadgroup you can skip the GROUP group consumer arguments. This almost certainly doesn't matter, but thought I'd mention it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you, I was considering it, but it should be another if or another case... So i left it like it is :-).

Copy link
Member

@BridgeAR BridgeAR May 10, 2019

Choose a reason for hiding this comment

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

It could be implemented in line 136 as:

      for (i = commandName === 'xread' ? 0 : 3; i < args.length - 1; i++) {

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM. The comments are not a blocker but a nice to have.

if (args[i].toUpperCase() === 'STREAMS') {
for (var j = i + 1; j < (args.length - 1); j++) {
if (String(args[i]).toUpperCase() === 'STREAMS') {
for (j = i + 1; j <= i + ((args.length - 1 - i) / 2); j++) {
Copy link
Member

@BridgeAR BridgeAR May 10, 2019

Choose a reason for hiding this comment

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

It could be implemented in line 136 as:

      for (i = commandName === 'xread' ? 0 : 3; i < args.length - 1; i++) {

commands.json Outdated
"flags": [
"write",
"noscript",
"movablekeys"
],
"keyStart": 1,
"keyStop": 1,
"step": 1
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind updating the whole commands.json instead of manually updating this entry? That can be done by running npm run build in combination with the newest Redis version.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done and done. This is my first contribution ever, thank you for your patience.

@BridgeAR BridgeAR merged commit 43b4efe into NodeRedis:master May 10, 2019
@BridgeAR
Copy link
Member

@borsucok thanks a lot!

@borsucok borsucok deleted the fix-stream-commands branch May 10, 2019 08:21
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

3 participants