Skip to content

Conversation

@slorello89
Copy link
Collaborator

@slorello89 slorello89 commented Apr 11, 2022

Implements the LPOS command for #2055

Had to add a new Message type to accommodate.

@NickCraver, one thing that might be slightly controversial, I set rank to 1 and maxlen to 0 by default, this is operationally equivalent to not adding them at all but very much simplifies the message creation without having to do any other array/list allocations. LMK what you think of this.

Also is there a better way to extract an array of expected Value-types? maybe a new ResultsProcessor?

@slorello89
Copy link
Collaborator Author

Appveyor doesn't care for me 😆

@slorello89 slorello89 requested a review from NickCraver April 12, 2022 01:21
Copy link
Collaborator

@NickCraver NickCraver left a comment

Choose a reason for hiding this comment

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

Added comments on code so far (looking good, mostly formatting) - will check out tests in the AM with fresh eyes :)

@slorello89
Copy link
Collaborator Author

slorello89 commented Apr 12, 2022

@NickCraver - FYI I needed to add another ResultProcessor for handling a default value type since the ExecuteAsync method demands a reference type, not sure if that's meant to be.

Also, this line is redundant, maybe it should be nixed?

Copy link
Collaborator

@NickCraver NickCraver left a comment

Choose a reason for hiding this comment

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

I think this is looking good - added a few more thoughts, mainly around:

  • Using regions like a heathen!
  • ...and restricting the result processor more to the specific nil case :)

public Task<long> ListPositionAsync(RedisKey key, RedisValue element, long rank = 1, long maxLength = 0, CommandFlags flags = CommandFlags.None)
{
var msg = CreateListPositionMessage(Database, flags, key, element, rank, maxLength);
return ExecuteAsync(msg, ResultProcessor.Int64DefaultNegativeOne);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same on default

@NickCraver
Copy link
Collaborator

@slorello89 Yep I gotcha - added thoughts on there, and yeah we can nuke that line - feel free to throw in there since it'll be gone from history and is discussed here.

@slorello89 slorello89 requested a review from NickCraver April 12, 2022 12:28
Copy link
Collaborator

@NickCraver NickCraver left a comment

Choose a reason for hiding this comment

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

Your fantastic region-free artisanal code is looking awesome, thanks for this!

@NickCraver
Copy link
Collaborator

@slorello89 Just adding release notes - will merge once builds are good :)

@slorello89
Copy link
Collaborator Author

Isn't a lack of preprocessor directives one of the pillars of "clean code"? 😆

@NickCraver NickCraver merged commit fffb5c1 into main Apr 12, 2022
@NickCraver NickCraver deleted the feature/LPOS branch April 12, 2022 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants