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

add default slot and keys recognition #754

Merged
merged 1 commit into from
Mar 16, 2023

Conversation

anatolysergeev
Copy link
Collaborator

add default connection for commands without a key and for multiple key commands with the limitation that all keys have to be in the same slot

#673

@anatolysergeev anatolysergeev requested a review from a team as a code owner February 9, 2023 09:09
def encode(data: Iterable[A])(implicit codec: BinaryCodec): Chunk[RespValue.BulkString] =
data.foldLeft(Chunk.empty: Chunk[RespValue.BulkString])((acc, a) => acc ++ input.encode(a))
def encode(data: Iterable[A])(implicit codec: BinaryCodec): RespCommand =
data.foldLeft(RespCommand.empty)((acc, a) => acc ++ input.encode(a))
}

final case class EvalInput[-K, -V](inputK: Input[K], inputV: Input[V]) extends Input[(String, Chunk[K], Chunk[V])] {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Controversial idea. What Is interface ideally wanted: inputK would have type KeyInput[K] that inherit Input[K] and we can translate there any dependency, but we cannot to do that cause we have to have contramap that in the inherited interface that return main trait Input. 🤔
@mijicd What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about that one. Can you draft some poc and let's see what are the pros and cons?

@anatolysergeev anatolysergeev marked this pull request as draft February 9, 2023 15:13
@anatolysergeev anatolysergeev marked this pull request as ready for review February 12, 2023 18:26
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.

Please split the pull request as suggested, and I'll re-review 🙏

redis/src/main/scala/zio/redis/ClusterExecutor.scala Outdated Show resolved Hide resolved
redis/src/main/scala/zio/redis/RespValue.scala Outdated Show resolved Hide resolved
redis/src/main/scala/zio/redis/RespValue.scala Outdated Show resolved Hide resolved
@@ -27,7 +27,7 @@ trait BaseSpec extends ZIOSpecDefault {

/* TODO
* We can try to support the most unsupported commands for cluster with:
* - default connection for commands without a key and for multiple key commands with
* - [DONE] default connection for commands without a key and for multiple key commands with
Copy link
Member

Choose a reason for hiding this comment

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

I guess we can remove the [DONE] :)

def encode(data: Iterable[A])(implicit codec: BinaryCodec): Chunk[RespValue.BulkString] =
data.foldLeft(Chunk.empty: Chunk[RespValue.BulkString])((acc, a) => acc ++ input.encode(a))
def encode(data: Iterable[A])(implicit codec: BinaryCodec): RespCommand =
data.foldLeft(RespCommand.empty)((acc, a) => acc ++ input.encode(a))
}

final case class EvalInput[-K, -V](inputK: Input[K], inputV: Input[V]) extends Input[(String, Chunk[K], Chunk[V])] {
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure about that one. Can you draft some poc and let's see what are the pros and cons?

Comment on lines +10 to +11
val key = RespArgument.Key("hello world")
assertTrue(15332 == key.asCRC16)
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick (I'm fine with leaving it as it is as well):

Suggested change
val key = RespArgument.Key("hello world")
assertTrue(15332 == key.asCRC16)
assertTrue(15332 == RespArgument.Key("hello world").asCRC16)

@anatolysergeev anatolysergeev merged commit 348a2ba into zio:master Mar 16, 2023
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