ruby-on-railssidekiq

What is the difference between perform_later and perform_async?


According to ActiveJob docs to enqueue a job I should use perform_later. Sidekiq docs implement perform_async, but the ActiveJob part of the docs suggests using perform_later. I've used perform_async previously in Rails, so do these differ in any way or is it just convention?


Solution

  • ActiveJob is a wrapper around the most known background job gems to provide a base API to work with background jobs.

    ActiveJob defines perform_later. Sidekiq defines perform_async. Which method you use depends on how you implemente your workers. If you use ActiveJob workers then you must use perform_later, if you don't use ActiveJob and just go with plain Sidekiq workers then use perform_async.