-
Notifications
You must be signed in to change notification settings - Fork 25
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
question about transaction management? #15
Comments
I am not the author of this library, but I will try to answer your question. |
Typically, in a REST project, a REST request would correspond to a single transaction. So, you would construct your ZIO as usual, including tzio's as needed within other operations, and in the end you would have a ZIO that has a Connection in the dependencies. Then, in the REST layer, you would run the transaction (e.g. using I'm not sure why you would have DDL actions when handling a REST request? Anyway, transaction-handling for DDL actions is DBMS-dependent. On some DBMS, they are considered part of the transaction and will be rollbacked if needed, on other they will be applied immediately and can't be rollbacked, and it can even differ for different actions (e.g. dropping a table vs creating one). Nothing I can do about it. Does that answer your question? |
@gaelrenoux yes, thanks 👍 |
Thanks for the tranzactio code, I experimented a bit on a fork against a local postgres, but wasn't sure if creating a PR for a question was pertinent?
I have a running REST-ZIO-Doobie-HikariTransactor-project, and I would like to make it more clear in terms of transaction management.
But with tranzactio, if I add a unique constraint and duplicate insert of alexander in an AppLayer, should each
TranzactIO[_]
/tzio
be a transaction, or the whole thing._ <- PersonQueries.insert(Person("Alexander", "Harris")).orElse(Task.succeed(()))
Looks like everything is rolled back including the DDL, but then I don't know how have that happen per REST-service-request.
Nor how to have something like
orElse
catch an error and actually compensating with a DML (eg inserting on an error message log or status)Anyway, any help is appreciated :)
The text was updated successfully, but these errors were encountered: