gocardless / statesman

A statesmanlike state machine library.
https://gocardless.com/blog/statesman/
MIT License
1.79k stars 163 forks source link

Rescue from failed transition to another state #527

Open ingemar opened 11 months ago

ingemar commented 11 months ago

Hello,

First off, thank you for the excellent work on this state machine!

I have a feature suggestion. Would it be possible to incorporate a mechanism that allows rescuing failed transitions by enabling a transition to an alternate state?

Conceptually, I envision something along these lines:

class MyStatesMachine
  include Statesman::Machine

  state :draft, initial: true
  state :created
  state :published
  state :failed

  rescue_from_failed_transition_to :published, with: :failed

  # ...
end

If you think this feature is a good fit and it makes sense for future plans, I'd be stoked to help out by submitting a pull request. Please let me know if you would be open to reviewing and considering it.

Looking forward to your feedback.

ingemar commented 10 months ago

Ping @lawrencejones, @thom-oman. 😊