-
Notifications
You must be signed in to change notification settings - Fork 63
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
[548] Expose Redis operations via Redis trait #727
[548] Expose Redis operations via Redis trait #727
Conversation
Am I missing something? This PR seems to contain only benchmarks. |
@mijicd you scared me there a bit :) but i see all the changes, not just in the benchmark module |
I guess it's GitHub app issue. I'll check it out from laptop. |
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.
Almost there :)
private[redis] def run(in: In)(implicit executor: RedisExecutor, codec: BinaryCodec): ZIO[Any, RedisError, Out] = | ||
executor | ||
.execute(resp(in, codec)) | ||
.flatMap[Any, Throwable, Out](out => ZIO.attempt(output.unsafeDecode(out)(codec))) | ||
.refineToOrDie[RedisError] | ||
|
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.
If we're going with implicits, then:
- let's keep the implicits alphabetically ordered
- let's use an alias -
IO[RedisError, Out]
as return type (this is also applicable to the commands) - let's remove the other
run
Otherwise, we can try passing codec
and executor
as constructor parameters here.
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.
I don't insist on implicits, it was just a way to get things done faster. I can make them "explicit" args or constructor params. Makes probably more sense as a constructor param as you suggested. Any particular order? Second argument list?
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.
Sure. It probably makes sense grouping it that, but I'm also fine if you place them in the same one.
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.
i made them constructor params in second argument list. Only complication was AskingCommand
. I resolved it but not sure if it's the best way.
trait CommandExecutor { | ||
implicit def codec: BinaryCodec | ||
|
||
implicit def executor: RedisExecutor | ||
} |
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.
Let's rename it somehow, as this is not really an executor.
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.
yeah i was struggling with naming this one, considering those two methods were making Redis trait before this change. could it be something like RedisEnvironment
or CommandExecutable
. Any suggestion?
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.
Environment sounds good. They don't need to be implicit anymore either. The question remains: can we remove it completely?
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.
i don't think we can, unless we want to split command creation and execution. If we changed API traits to return RedisCommand
and pushed invocation of run
then we wouldn't need these dependencies on those traits. Or do you have some ideas?
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.
I would not "expose" run. As mentioned below, 2nd parameter group is a bit too much as well, imo. On the other side, it makes sense if we restore implicits. 🤔
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.
i mean't something like zio-dynamodb does, where you wrap command and arguments in some internal class which exposes method like
def execute: ZIO[RedisExecutor & BinaryCodec, RedisError, Out]
but that's different issue imho
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.
That's not bad. We might be able to combine it with returning
somehow and make a nice "proxy", but let's leave it for the follow-up PR (if you're willing to dig into it :) ).
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.
Looks really good to me. Two minor things and it's ready to go.
|
||
import zio.schema.codec.BinaryCodec | ||
|
||
trait RedisEnvironment { |
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.
Maybe we should make it package-private. After all, it is an implementation detail.
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.
yes, makes sense
executor: RedisExecutor, | ||
codec: BinaryCodec |
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.
I'm not sure about this parameter group. Let's merge them in the first one (sorry 🙏 )
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.
done
@m-kalai Please adjust the docs examples and it's ready to go. |
Resolves #548
Redis
environment dependency from all the API traitsRedis
traitredis
package object and fixing tests