The DEV Team profile image The DEV Team

Call for Contributions: Move DelayedJob Calls to ActiveJob

twitter logo github logo ・1 min read

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
  • [ ] MembershipMailer.delay.new_membership_subscription_email
  • [ ] MembershipMailer.delay.subscription_update_confirm_email
  • [ ] MembershipMailer.delay.subscription_cancellation_email
  • [ ] user.follow
  • [ ] reaction.create
  • [ ] ArticleAnalyticsFetcher.new.update_analytics
  • [ ] HtmlVariantSuccess.create
  • [ ] HtmlVariantTrial.create
  • [ ] message.send_push
  • [ ] RssReader.new.fetch_user
  • [ ] several calls in trigger_delayed_index

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 job perform_later call
  • you may need to modify the existing tests by using perform_enqueued_job instead of run_background_jobs_immediately helper

Remember to pass record ids (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!

twitter logo DISCUSS (2)
The team behind this very platform. πŸ˜„
markdown guide
 

If you are like me who is new to Ruby on Rails (RoR) and are unsure what is ActiveJob vs DelayedJob:

  • DelayedJob is one of the background job systems in RoR. There are also other job systems such as Resque or Sidekiq.
  • ActiveJob is a wrapper on top of DelayedJob. It's an abstraction layer that gives you freedom to switch the underlying job system implementation. E.g., you can use ActiveJob with DelayedJob and later switch to Resque without having to rewrite job code.

Read more:

 

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

cyrillefr avatar
cyrillefr commented on Jun 19, 2019
- add AJ job + job spec
- refactor call

What type of PR is this? (check all applicable)

  • [x] Refactor
  • [ ] Feature
  • [ ] Bug Fix
  • [ ] Documentation Update

Description

Move HtmlVariantTrial.create delay calls to ActiveJob

Related Tickets & Documents

#3136

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

Added to documentation?

  • [ ] docs.dev.to
  • [ ] readme
  • [x] no documentation needed

[optional] What gif best describes this PR or how it makes you feel?

alt_text

Classic DEV Post from Apr 18

The Weird Rules I Set Myself That Got Me a Job

The DEV Team profile image
The hardworking team behind dev.to ❀️

Want to contribute to open source and help make the DEV community stronger?

All the dev.to code is freely available on GitHub.

You're welcome to jump in!