-
Notifications
You must be signed in to change notification settings - Fork 64
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
Implement transactions API #156
Comments
Redis transaction API consists of two groups of commands:
The latter can be (relatively) easily implemented via the existing primitives, while the former requires more attention. There are a few things to keep in mind:
With that in mind, here's the rough idea for a primitive that we could use to represent transactions: sealed trait RedisTransaction[+Out] {
def commit: ZIO[RedisExecutor, RedisError, Out]
// zip operators
}
object RedisTransaction {
final case class Single[In, Out](command: RedisCommand[In, Out], in: In) extends RedisTransaction[Out]
final case class Zip[A, B](left: RedisTransaction[A], right: RedisTransaction[B]) extends RedisTransaction[(A, B)]
final case class ZipLeft[A, B](left: RedisTransaction[A], right: RedisTransaction[B]) extends RedisTransaction[A]
final case class ZipRight[A, B](left: RedisTransaction[A], right: RedisTransaction[B]) extends RedisTransaction[B]
} Note that this API forces user to be explicit about transaction boundaries. Internally, its "interpreter" would take care of all protocol details, e.g., calling commit would build a MULTI ... EXEC block at one point. @anovakovic01 please take a look and let me know if you have any questions about it. Also, don't take this design as absolute truth - as said, it's just a rough idea. |
@mijicd Thanks for the instructions. I think that I've understood the base idea. Draft PR will be sent as soon as I sketch something. |
Anyone still working on this? |
@anovakovic01 is, he can share the current state, and perhaps you could pair up. |
Would be happy to assist where I can! |
@barthorre Sorry for waiting for an update this long. I'm still working on this one, should send a draft PR soon. It should introduce a single abstraction that will unify both transactions and the regular commands. When API is defined we'll need to update the executor to be able to process transactions. Help will be needed on that part. |
Extracted from this comment authored by @regis-leray.
Commands
Tips
zio.redis.api
.zio.redis.options
.zio.redis.Input
andzio.redis.Output
, respectively.zio.redis.InputSpec
andzio.redis.OutputSpec
, respectively.zio.redis.ApiSpec
.The text was updated successfully, but these errors were encountered: