Open zspencer opened 4 weeks ago
@zspencer I would like to work on this
We'd love the help!
Do you have an idea for how you'd like to go about it?
@zspencer, I was thinking to wrap the block in a transaction like you suggested and use after_commit
callback to run the sidekiq jobs. This would ensure that only after the transaction succeeds the next steps would be executed.
To be specific the below lines would be placed inside the after_commit
callback
Order::ReceivedMailer.notification(order).deliver_later
order.events.create(description: "Notifications to Vendor and Distributor Sent")
Order::PlacedMailer.notification(order).deliver_later
order.events.create(description: "Notification to Buyer Sent")
SplitJob.perform_later(order: order)
We can use after_rollback
callback to handle use cases when transaction gets rolled back
I have referred the docs for this: https://api.rubyonrails.org/classes/ActiveRecord/Transaction.html
Do let me know if this approach would suffice or if I am missing something
Hello!
Can you please take a look at such a solution)
PR: https://github.com/zinc-collective/convene/pull/2634
Thanks in advance!)
Our current implementation can leave orders in strange spots if they fail in the middle.
On the one hand, this is good because we don't want to redo important steps that have already happened.
On the other, it's not great because if step B updates the order to paid and step C fails then D and E don't happen and never will.
It would probably be better to either:
Thoughts?