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

List api test executor #328

Merged
merged 11 commits into from
Mar 24, 2021
Merged

List api test executor #328

merged 11 commits into from
Mar 24, 2021

Conversation

hcwilhelm
Copy link
Contributor

Closes: #195

Support all currently implemented List API Commands including the Blocking commands.

Two commands are missing in the API and thus not included in this PR. See : #324 #325

@hcwilhelm hcwilhelm requested a review from a team as a code owner March 23, 2021 15:02
@hcwilhelm hcwilhelm force-pushed the list-api-test-executor branch from d14eef0 to a187233 Compare March 23, 2021 16:06
Copy link
Member

@mijicd mijicd 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 few minor comments, otherwise looks almost ready to go!


private[redis] final class TestExecutor private (
lists: TMap[String, Vector[String]],
Copy link
Member

Choose a reason for hiding this comment

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

I'd use Chunk instead of Vector.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok changed to Chunk

private def errResponse(cmd: String): RespValue.BulkString =
RespValue.bulkString(s"(error) ERR wrong number of arguments for '$cmd' command")

private def onConnection(command: String, input: Chunk[RespValue.BulkString])(
res: => RespValue.BulkString
): USTM[BulkString] = STM.succeedNow(if (input.isEmpty) errResponse(command) else res)

private[this] def runCommand(name: String, input: Chunk[RespValue.BulkString]): STM[RedisError, RespValue] = {
private[this] def runCommand(name: String, input: Chunk[RespValue.BulkString]): USTM[RespValue] = {
Copy link
Member

Choose a reason for hiding this comment

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

We should make sure no unsafe calls are made, e.g. head on potentially empty chunk. It can (and should) be done in a separate pull request.

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 am not sure if I understand what you are trying to say here. From my point of view, we statically know which inputs we feed into each command and therefore we are able to decode the input even with the use of unsafe operations like head etc. How do you imagine that we ensure that no unsafe calls are made?

Copy link
Member

Choose a reason for hiding this comment

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

What I meant is double-checking if we know statically (last time I took a look there were quite a few head calls), and if now, changing the type to NonEmptyChunk :). If there's nothing to be done here, it's a no-op (even better :) ).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alright got it. But as you said this can be done in a follow-up PR.

redis/src/main/scala/zio/redis/TestExecutor.scala Outdated Show resolved Hide resolved
redis/src/main/scala/zio/redis/TestExecutor.scala Outdated Show resolved Hide resolved
redis/src/main/scala/zio/redis/TestExecutor.scala Outdated Show resolved Hide resolved
@mijicd mijicd merged commit f76fce2 into zio:master Mar 24, 2021
hcwilhelm added a commit to hcwilhelm/zio-redis that referenced this pull request Mar 24, 2021
List api test executor (zio#328)
@hcwilhelm hcwilhelm deleted the list-api-test-executor branch September 6, 2023 06:58
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.

Add lists api to test executor
2 participants