-
Notifications
You must be signed in to change notification settings - Fork 1
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: add list collection #43
Conversation
pratik151192
commented
Jan 9, 2024
•
edited
Loading
edited
- feat: add all APIs for list collection
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a couple small things. Looks good!
* @param listName The name of the list to fetch from. | ||
* @param startIndex The starting index of the range (inclusive). | ||
* @param endIndex The ending index of the range (exclusive). | ||
* @return The result of the list fetch operation: [ListFetchResponse.Hit] or [ListFetchResponse.Miss]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should include ListFetchResponse.Error.
* | ||
* @param cacheName The name of the cache containing the list. | ||
* @param listName The name of the list to measure. | ||
* @return The result of the list length operation: [ListLengthResponse.Success] or [ListLengthResponse.Error]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This Is a Hit/Miss/Error.
public data class Hit(private val byteArrayValues: List<ByteArray>) : ListFetchResponse { | ||
|
||
/** Retrieves the values as a list of byte arrays. */ | ||
public fun valueListByteArray(): List<ByteArray> = byteArrayValues |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the other responses that return something, we're exposing the values as properties instead of getter functions. GetResponse
contains an example. valueListByteArray
can be a public val and valueListString
can be a lazy initializer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool
public data class Hit(private val value: ByteArray) : ListPopBackResponse { | ||
|
||
/** Retrieves the value as a byte array. */ | ||
public fun valueByteArray(): ByteArray = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here with values vs methods.
public data class Hit(private val value: ByteArray) : ListPopFrontResponse { | ||
|
||
/** Retrieves the value as a byte array. */ | ||
public fun valueByteArray(): ByteArray = value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here as well.
require(!listName.isNullOrBlank()) { LIST_NAME_IS_REQUIRED } | ||
} | ||
|
||
internal fun requireValidValue(value: Any?) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed? Arguments that can't be null just won't be marked nullable.
} | ||
|
||
internal fun requireValidListName(listName: String?) { | ||
require(!listName.isNullOrBlank()) { LIST_NAME_IS_REQUIRED } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is minor, but are empty list names valid? For some reason I thought the server accepted them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right! Empty list names are indeed accepted.
03f35aa
to
a08c050
Compare