-
Notifications
You must be signed in to change notification settings - Fork 36
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 transaction support #31
base: master
Are you sure you want to change the base?
Conversation
Couple questions:
|
In the hooks, a user does not have to pass the
Yes, but I'd like to nail down the approach first.
Many endpoints have to schedule jobs, hit third party services, or alter another part of the db. The specific use case I am looking for is writing an event to another table within the dband hitting a 3rd-party service. |
"A Note About Transactions" in the sequelize hooks docs (sorry, no anchor tags on the headers) has a more info as well. |
Correct me if I’m wrong but right now your implementation uses managed
transactions which might make it hard to work with non promise based third
party tooling. We probably want to expose a way to pass in transaction
options to use with an unmanaged transaction style that the user can commit
and rollback more freely? So maybe the implantation takes in translation
options in any pre write hook and then be accessed to finalize in any post
write hook? Let me know what you were thinking though
…On Mon, Oct 1, 2018 at 4:50 PM Andrew Madonna ***@***.***> wrote:
"A Note About Transactions" in the sequelize hooks docs
<http://docs.sequelizejs.com/manual/tutorial/hooks.html> (sorry, no
anchor tags on the headers) has a more info as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACELE3wHxIrwIOnYyS590R2EhiJQ6WxXks5ugo4QgaJpZM4XCeTx>
.
|
@tommybananas A simple approach may be that a user can add an unmanaged transaction to the |
@tommybananas I updated the code with the new approach. One concern I have with this, is if an error occurs somewhere along all the hooks, including internal lib hooks, what's the best way to rollback? |
@awm33 couple thoughts. One is that it might make sense to change default error and final milestone handlers to check for transactions and commit/abort automatically for simple cases and minimizing boilerplate. I'm not a huge fan of requiring the override of the error handler because they are separate things and making them reimplement the error handler seems like a bad idea. Another option would be a separate milestone for transactions.. just brainstorming. |
but I am open to getting the first run of this feature out asap so long as we document it and write a test or two. |
@tommybananas I think the approach is close and I'm starting on tests. I think I need to add some error handling, since we can't really handle that by adding a hook. An error can occur anywhere, and would short circuit, and we would probably want to rollback on error. It looks like the error handling is here? https://github.com/tommybananas/finale/blob/master/lib/Controllers/base.js#L179 It looks like we would want to add transaction error handling to each I'm thinking there if If that error handling is in place, I think the rest can be managed using milestone hooks. Thank you for helping me through this approach. |
hmm.. I guess that makes sense. I'm trying to figure out if there would ever be a reason they would not want to rollback the tx on error. In which case they would have to basically override all the error handlers in order to prevent the automatic rollback which would be a pain. But seeing as you are the only one requesting this functionality.. I'm fine with it. If you can add documentation at the very least I will merge this. Thanks for your contribution |
I want this feature... |
Once a complete PR is created I’ll go ahead and merge
…On Tue, Feb 26, 2019 at 6:03 AM hiradimir ***@***.***> wrote:
I want this feature...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#31 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACELE-u-LU6v2hWKHqJHvyfi5_kzQVloks5vRSKegaJpZM4XCeTx>
.
|
Adds transaction. With this PR,
hooks
can optionally make use of the transaction by adding it to the context in a pre-hook and committing in a post-hook.Addresses #16