momentohq/client-sdk-rust

Decide on default arguments for sorted set fetch by rank and score

Closed this issue · 3 comments

The sorted_set_fetch_by_rank and sorted_set_fetch_by_score functions in the new cache client both take cache name, sorted set name, and sort order, and they both return the same response object. i.e. they are the same function. We need to figure out which additional arguments we should add to either of them to separate them.
Idea:
sorted_set_fetch that takes cache name, sorted set name, sort order, limit, offset
sorted_set_fetch_by_rank that takes cache name, sorted set name, sort order, start_rank, end_rank
sorted_set_fetch_by_score that takes cache name, sorted set name, sort order, min_score, max_score

Fetch by score and rank appear to have optional arguments in all the SDKs they're implemented in:

Though Java has multiple signatures:

Rust could:

  • Provide the same 5 APIs but with different names bc no overloading in Rust
  • Provide only 1 API: SortedSetFetch that accepts cache name and sorted set name, and direct users to build their own FetchByRank or FetchByScore requests if they want to use those
  • Provide 3 APIs: SortedSetFetch that accepts cache name and sorted set name, and FetchByRank and FetchByScore with their differentiating optional args (sort order, start/min, end/max)
  • Leave as 2 APIs with non-optional differentiating args (sort order, start/min, end/max)
  • Leave as 2 APIs with optional argument builders

During meeting, decided to:

  • Not change the fetch by score API, docs should point to using the request builder since there are so many optional args that can be used in any combination that works for the user
  • Include start and end rank as part of the fetch by rank API as it seems likely users will use that API to page through their sorted set