Out of the box async operations #1749
Unanswered
jwoertink
asked this question in
Feature requests & Ideas
Replies: 1 comment
-
In a past life we used a system similar to Operations, and it looked like this: # contrived example is contrived
class BigDealContext < BaseContext
inputs :user, :deal
def perform
user.make_a_deal deal
end
def later
user.notify_dealio if deal.succeeded?
end
end And honestly I underestimated the power of that pattern when we built it so much. There are so many situations you can defer just a bit of logic out to the background and speed up your app. We were using sidekiq to run processes and we had one "later context runner" sidekiq job which handled sorting out the context and deserializing the parameters and other mumbojumbo. The ability to asynchronize a bit of code quickly, easily and offload it to some non-request-cycle portion of the app easily is a game changer. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've had this idea for a bit now, but I wonder if it would be of any interest to others for having operations that could be ran asynchronous out-of-the-box....
We have this capability with Carbon's deliver_later_strategy. This allows you to decide if you just want to use
spawn
or if you want to use a background worker like Mosquito or Sidekiq.My idea for Avram would be the same thing. There would be an
Avram::AsyncOperationStrategy
or something with the default being set tospawn
. Then someone could make a separateAvram::AsyncOperation::MosquitoStrategy
. I'm not totally sure how it would work for Save/DeleteOperation, but at least the regular ones could haverun
andrun_later
.For example:
Does this sound like a good idea? Or doing too much and just let developers handle this when they want?
Beta Was this translation helpful? Give feedback.
All reactions