i am working on a rails app and currently we are migrating to jruby. we currently have over 10 after callbacks on the one of our models and this is blocking the response for a long time.
after_update :sync
after_update :send
after_create :add
after_create :add
after_create :send
after_update :track!
after_create :track!
after_create :send_welcome_email
after_create :track
after_update :send
after_update :set_is_active!
after_update :set_
after_create :apply
after_update :apply
after_update :clear
after_create :mark
i need to wrap/override activerecord's after callbacks (after_save, after_update) to run them asynchronously using concurrent-ruby to not block the response but i don't know how to do that the right way.
what i want to do is something like that
require 'concurrent'
class ApplicationRecord < ActiveRecord::Base
def after_update
Concurrent::Promise.new { super }.exec
end
end
i just need to know the right syntax and whether this is the right approach for something like that. would appreciate any suggestions.