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: add list collection #43

Merged
merged 2 commits into from
Jan 12, 2024
Merged

feat: add list collection #43

merged 2 commits into from
Jan 12, 2024

Conversation

pratik151192
Copy link
Contributor

@pratik151192 pratik151192 commented Jan 9, 2024

  • feat: add all APIs for list collection

@pratik151192 pratik151192 changed the base branch from main to add-list-caches January 9, 2024 00:58
Base automatically changed from add-list-caches to main January 9, 2024 17:31
Copy link
Collaborator

@nand4011 nand4011 left a 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].
Copy link
Collaborator

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].
Copy link
Collaborator

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
Copy link
Collaborator

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.

Copy link
Contributor Author

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
Copy link
Collaborator

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
Copy link
Collaborator

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?) {
Copy link
Collaborator

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 }
Copy link
Collaborator

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.

Copy link
Contributor Author

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.

@pratik151192 pratik151192 marked this pull request as ready for review January 12, 2024 00:34
@pratik151192 pratik151192 requested a review from nand4011 January 12, 2024 00:34
@pratik151192 pratik151192 merged commit 3b57e7d into main Jan 12, 2024
5 checks passed
@pratik151192 pratik151192 deleted the add-list-collection branch January 12, 2024 13:28
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