ruby-on-railsrubymultithreadingworkflowaasm

Thread safe of state machine gems in multi-tenant Rail app


There are a few popular Ruby state machine gems such as geekq/workflow and aasm. Are they thread safe in multi-tenant Rails 4.2 application?

I am using geekq/workflow which defines process definition on model class as class method. This makes me wonder if other users who login late will overwrite the previous users workflow definition.

Can some developer comment on the thread safe issue of state machine? Or recommend a state machine gem which is thread-safe in multi-tenant Rails app?


Solution

  • Those gems are designed to let you-the-developer define a workflow or state machine, where the possible states and the way they transition is the same for everyone. If that's what you're doing, then regardless of tenant, the workflow is set up at the beginning and never changes, and they are fine for multi-threaded, multi-tenant apps.

    If you are letting your users define workflows, I think they are simply not the right tool.