Hey folks, we've been working on a gradual migration from DelayedJob
to ActiveJob
within the DEV codebase.
Move delay calls to ActiveJob #3136
As described in #2497, to be less dependent of DelayedJob
we also need to move jobs which are created by calling delay
method to ActiveJob
:
Here is the list of the calls:
- [x]
Slackbot.ping
- [x]
reaction.create
- [x]
ArticleAnalyticsFetcher.new.update_analytics
- [x]
HtmlVariantSuccess.create
- [x]
HtmlVariantTrial.create
- [x]
message.send_push
- [x]
RssReader.new.fetch_user
- [x] several calls in
trigger_delayed_index
- [x]
index.delay.delete_object("users-#{id}")
- [x]
user.follow
- [x]
chat_channel.delay.index!
- https://github.com/thepracticaldev/dev.to/pull/4317
Actions for each of the calls:
- create a corresponding
ActiveJob
, specify a queue name - call the required method inside a job
- replace the
delay
method calls with a jobperform_later
call - you may need to modify the existing tests by using
perform_enqueued_job
instead ofrun_background_jobs_immediately
helper
Remember to pass record id
s (if needed) instead of ActiveRecord objects to a job to avoid deserialization errors (#1621)
Take a look at the issue. We have a lot of merged pull requests to use as a guideline to get you started, for example...
Moved send_mention_notification to ActiveJob #3566
What type of PR is this? (check all applicable)
- [x] Refactor
Description
- moved send_mention_notification to
ActiveJob
- used @copasetickid's pr and refined it
Related Tickets & Documents
#1996
Happy coding!
Oldest comments (2)
Actually, the linked "Moved send_mention_notification to ActiveJob" is even a bit more complex comparing to the remaining tasks.
For the more similar ones, you can look at the pull requests connected to the issue, like this one:
Move HtmlVariantTrial.create delay calls to ActiveJob (#3173) #3239
What type of PR is this? (check all applicable)
Description
Move HtmlVariantTrial.create delay calls to ActiveJob
Related Tickets & Documents
#3136
Mobile & Desktop Screenshots/Recordings (if there are UI changes)
Added to documentation?
[optional] What gif best describes this PR or how it makes you feel?
If you are like me who is new to Ruby on Rails (RoR) and are unsure what is ActiveJob vs DelayedJob:
Read more: