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

feat: Split sortedSetFetch up into ByRank and ByScore functions #280

Merged
merged 2 commits into from
Mar 13, 2023

Conversation

cprice404
Copy link
Contributor

As per the API design discussion and the pattern we established in the node.js SDK, this commit splits the SortedSetFetch into two functions, one for fetching by score and one for by rank. This prevents the user from needing to reason about which combinations of arguments are and are not legal together.

As per the API design discussion and the pattern we established
in the node.js SDK, this commit splits the SortedSetFetch into
two functions, one for fetching by score and one for by rank.
This prevents the user from needing to reason about which
combinations of arguments are and are not legal together.
momento/cache_client.go Outdated Show resolved Hide resolved
Comment on lines +15 to +16
StartRank *int32
EndRank *int32
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry maybe this has been discussed somewhere, but why do we use pointers for StartRank and EndRank?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's because we want to be able to use nil to express that we aren't specifying them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I know that that's how we did for SortedSetFetchByRank and SortedSetFetchByScore types, but I'm not sure why these were pointers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if they were not pointers, how would I express that I want to use the defaults?

You may be right that there is another way to do it! But that was my understanding.

Copy link
Contributor

@poppoerika poppoerika Mar 13, 2023

Choose a reason for hiding this comment

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

Oh I see. It makes sense pointers were used so that they can be nil since these can be "optional."

I think it makes sense for those values to be optional since ByScore and ByRank were a part of the fetch API's params.
But now we're breaking into two separate APIs specifically named ByScore and ByRank, it feels a bit weird for those values to be optional?
What do you think? @cprice404

Copy link
Contributor

Choose a reason for hiding this comment

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

But it looks like it's already decided in the API doc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are optional because you could pass either one of them or the other, or both.

For example, you could pass only EndRank of 10 if you wanted to get the first 10. Or you could pass only StartRank of 10 and then get all of the elements after the 10th one.

Also note that these numeric fields were pointers even inside of the ByRank/ByScore objects before.

Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense! Thank you for the clarification.

Yup, I saw that after leaving the above comment and figured that this is something decided with reasons.

Comment on lines +15 to +18
MinScore *float64
MaxScore *float64
Offset *uint32
Count *uint32
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above.
Why do we use pointers here?

momento/cache_client.go Outdated Show resolved Hide resolved
@cprice404 cprice404 requested a review from poppoerika March 13, 2023 21:26
Copy link
Contributor

@poppoerika poppoerika left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@cprice404 cprice404 merged commit 0a12ba3 into main Mar 13, 2023
@cprice404 cprice404 deleted the split-sorted-set-fetch branch March 13, 2023 21:52
cprice404 added a commit that referenced this pull request Mar 14, 2023
* feat: Split sortedSetFetch up into ByRank and ByScore functions

As per the API design discussion and the pattern we established
in the node.js SDK, this commit splits the SortedSetFetch into
two functions, one for fetching by score and one for by rank.
This prevents the user from needing to reason about which
combinations of arguments are and are not legal together.
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.

2 participants