Skip to content

v3.0.0 - `enqueue_all` & `perform_all_later` support!

Choose a tag to compare

@smudge smudge released this 08 Jun 17:13
· 18 commits to main since this release
Immutable release. Only release title and notes can be modified.
dbaf6a2

Changes incorporated into this release are primarily in support of enqueue_all and by extension ActiveJob.perform_all_later.

  • run_at / name defaulting moved from a before_save callback into Delayed::Backend::JobPreparer
    • Callers that bypass Delayed::Job.enqueue (e.g. raw Delayed::Job.create! / .save) will no longer have these defaulted and must supply them explicitly
  • Support for the :enqueue hook is now removed. Delayed jobs defining an :enqueue method will now raise upon enqueue indicating lack of support
  • Delayed::Worker.delay_jobs may no longer be a Proc. Job enqueues will raise if a Proc is assigned
  • The ActiveJob adapter now properly sets successfully_enqueued upon jobs being enqueued
  • ActiveJobs explicitly will no longer be accepted directly to Delayed::Job.enqueue and Delayed::Job.enqueue_all.
  • Both Delayed::Job and the ActiveJob adapter now support enqueue_all(enabling perform_all_later)
    • For all ActiveJob enqueue methods(perform_later, perform_all_later), provider_job_id is now only set for applications where ActiveRecord::Base.connection.supports_insert_returning? == true(ie: Postgres + SQLite on Rails 7.1+)
    • The :enqueue lifecycle event now accepts an array of jobs rather than a single job
    • Similarly, the delayed.job.enqueue ActiveSupport notification now emits a hash with an array of jobs(see more in upgrade guide)

Upgrade Guide

Recommended:

  • Apply new migrations to mark run_at and name as non-nullable columns on delayed_jobs
    • 08_add_run_at_and_name_not_null_check.rb to set up unvalidated constraints(Postgres only)
    • 09_validate_run_at_and_name_not_null.rb to mark run_at and name as non-nullable
      • You must backfill run_at and name for this migration to run successfully

Required:

  • Remove any enqueue hooks you have on Delayed::Job
  • Ensure Delayed::Worker.delay_jobs is never set to a Proc within your application
    • Ensure Delayed::Worker.delay_job?(job) is no longer used, as it was removed
  • Ensure you have no instances of passing an ActiveJob directly to Delayed::Job.enqueue, switching to use perform_later instead
  • Audit your usage of provider_job_id if your backing database does not support insert returning
  • Adjust your lifecycle callback plugins to ensure your consumption of the :enqueue expects an array of jobs
  • Adjust your consumption of the delayed.job.enqueue ActiveSupport notification

Full Changelog

  • fix: Update changelog_uri to GH releases by @smudge in #101
  • style: Add (passing) tests for regression coverage by @smudge in #102
  • refactor: Push run_at / name defaulting into JobPreparer by @CelticMajora in #104
  • refactor: deprecate :enqueue job hook by @CelticMajora in #106
  • refactor: Drop support for Delayed::Worker.delay_jobs being proc by @CelticMajora in #108
  • feat: Implement enqueue_all by @CelticMajora in #103
  • fix: switch aj adapter to pipe through enqueue_all by @CelticMajora in #111
  • fix: README to reflect accurate enqueue lifecycle shape by @CelticMajora in #112
  • fix: Assert ActiveJobs can not be passed directly to DJ enqueue methods without going through the adapter by @CelticMajora in #113

New Contributors

Full Changelog: v2.2.0...v3.0.0