I recently wrote a blog post about how Wanelo uses events and observers in plain ruby, to model application events. The base code that supports it is available in the open sourced gem ventable.
If you want your business logic "glue" to look like this below, read the above blog post.
If you want your business logic "glue" to look like this below, read the above blog post.
Wanelo::Event::ProductSave.configure do notifies Product, SaveNotification, SaveAction, inside: :transaction notifies ProductSaveWorker, ResaveEmailWorker endWe have found so many applications of using events in the backend Rails application, that I can not imagine building another app without it.
Having said that, right now Ventable does not support distributed events. But it absolutely could! I am considering writing a plugin for sidekiq background processing framework, that could notify any observer via a background job, and not inside the current ruby thread. Another option is to use another thread! Lots of options for concurrency.
Perhaps one day, it will look like this:
Wanelo::Event::ProductSave.configure do notifies Product, SaveNotification, SaveAction, inside: :transaction notifies PostSaveProcessor, via: :worker notifies ResaveEmailWorker, via: :thread end
Comments