-
Notifications
You must be signed in to change notification settings - Fork 127
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
Transaction API is confusing #54
Comments
how do you think
? |
First, I vehemently disagree that That said, you are of course right that
What to do about it:
|
@qrilka, your scenario is impossible in Redis (and Hedis). |
@qrilka Thank you for perfectly illustrating what's confusing about |
@informatikr I agree that The name To be clear: my proposal is to keep the name I'd like to help out on this: if you have thoughts on the order in which things have to be done then that'd be great! |
@benjamin-hodgson Don't be snide. Removing a Monad instance will not remove the need that people read the documentation of their database, or a compiler error will be the least of their worries. And if it were sufficient that the code "looks correct" we would all be using JavaScript and wonder why To also be clear, I think your proposal is good and we should keep it in mind (and this issue open). |
I'm sorry for coming across as snide. It wasn't my intention. What do you think are the next steps? |
@benjamin-hodgson I don't think that you were snide here - it looks that I was carried away by thoughts on |
No worries. Unless @k-bx has a different view on this, I would postpone any changes to the multiExec API until
So if you want to work on this right now, a concept for point 2. above would be a step forward. This would be either changing I realize, this might not be very clear and helpful. But this is because, right now, there is no clear plan how to move forward. I hope it helps, anyway. |
I fully agree with @informatikr 's point in last comment. Removing Either seems more important (and possibly breaking change, for which we might want to look for other alternatives like keeping old interface and providing a new one). I'd wait for ApplicativeDo as well for this Applicative migration. |
I spent a few hours hacking away at replacing the Here's an example of a sequence of commands that will be pipelined with the current version of m = do
x <- get "foo"
y <- get "bar"
return $ somePureComputation x y Compare with a computation that cannot be pipelined: m = do
x <- get "foo"
case x of
l@(Left _) -> return $ l
Right Nothing -> return (Left "no foo")
Right (Just result) -> set "bar" result Scrutinising Note that pipelined commands behave very differently from non-pipelined commands with regards to errors. In the computation... m = do
x <- lpop "foo"
set "bar" "baz" ... what should happen if So pipelining is another example of a feature that can only correctly support an
My preference would be the first option, because it helps users fall into the "pit of success". Fail-fast error handling is almost always what you want, and I think you should have to explicitly opt out (by working in a different monad) if you want the extra performance of pipelining. What do you think? Can you think of any other options? Happy to move this discussion to a new issue if you prefer. |
@benjamin-hodgson I think option 3 is the way to go, actually. While I would by default stick to something like option 1, I suspect this would affect performance too much on one hand, and I think redis's commands are simple enough to state that having error-responses is something which should happen very rare (and be fixed quickly). So if that is implementeable without breaking pipeline – I'd go with throwing IO exceptions. |
Regarding the three options:
|
Automatic pipelining is fast and cool, but not safe, due to the way it affects error handling. I understand that you're unwilling to change the default (though I'd love to change your mind!), but I think this pitfall should at least be documented. I'd also like it to be convenient to turn off (that is, it should not require a ton of In the mean time, I'll look into whether raising exceptions in IO affects pipelining. |
I recently answered a Stack Overflow question in which the questioneer was confused about the meaning and usage of the
Queued
type. I agree with them: theQueued
type and the multi-parameterRedisCtx
class do seem unintuitive.In my answer, I argued that a monadic interface is not the right abstraction for Redis transaction batches. I also gave an outline of a simpler
Applicative
interface on top ofRedisTx
, which does away with the confusing elements of the current design:Is there an appetite for changing the
hedis
API to remove theQueued
type and expose a purely-applicative interface forRedisTx
? It'd be a breaking API change, and the work would likely involve changing theMonadRedis
/RedisCtx
hierarchy.I'd be keen to make a pull request for this, but I wanted to gauge interest before I get started so as not to waste anyone's time.
The text was updated successfully, but these errors were encountered: