Skip to content

Commit

Permalink
Use new AJ wrapper name
Browse files Browse the repository at this point in the history
  • Loading branch information
mperham committed Jan 2, 2025
1 parent 64f1194 commit 4d80a26
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
11 changes: 6 additions & 5 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@
HEAD / main
----------

- **BREAKING** The `created_at` and `enqueued_at` attributes are now stored as
- **WARNING** The underlying class name for Active Jobs has changed from `ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper` to `Sidekiq::ActiveJob::Wrapper`.
- **WARNING** The `created_at` and `enqueued_at` attributes are now stored as
integer milliseconds, rather than epoch floats. This is meant to avoid precision
issues with JSON and JavaScript's 53-bit Floats. Example:
`"created_at" => 1234567890.123` -> `"created_at" => 1234567890123`.
`"created_at" => 1234567890.123456` -> `"created_at" => 1234567890123`.
- **NEW FEATURE** Job Profiling is now supported with [Vernier](https://vernier.prof)
which makes it really easy to performance tune your slow jobs.
The Web UI contains a new **Profiles** tab to view any collected profile data.
Please read the new [Profiling](https://github.com/sidekiq/sidekiq/wiki/Profiling) wiki page for details.
- Refactor Sidekiq::Web to simplify the code and improve security [#6532]
- Refactor `Sidekiq::Web` to simplify the code and improve security [#6532]
- Default error logging has been modified to use Ruby's `Exception#detailed_message` and `#full_message` APIs.
- CI now runs against Redis, Dragonfly and Valkey.
- The Web UI's language picker now shows options in the native language
- Remove global variable usage within the codebase
- Adjust Sidekiq's default thread priority to -1 for a 50ms timeslice. This can help avoid TimeoutErrors
when Sidekiq is overloaded. [#6543]
- Adjust Sidekiq's default thread priority to -1 for a 50ms timeslice.
This can help avoid TimeoutErrors when Sidekiq is overloaded. [#6543]

7.3.8
----------
Expand Down
9 changes: 7 additions & 2 deletions docs/8.0-Upgrade.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,16 @@ This reduced CSS from 160KB to 16KB and average page render time from 55ms to 3m
See pull request [#6532](https://github.com/sidekiq/sidekiq/pull/6532) for more details.
3rd party Sidekiq Web extensions may look poor until they adapt to the new CSS.

### Miscellaneous
### Data Model Changes

- The underlying class for Active Jobs has changed from `ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper` to `Sidekiq::ActiveJob::Wrapper`.
This can save a significant amount of memory when creating a large number of Active Jobs.
- The `created_at` and `enqueued_at` values within the job payload have changed type.
Previously they were stored at epoch floats (1234567890.123456). They are now stored as
epoch milliseconds (1234567890123) in order to avoid floating point.
epoch milliseconds (1234567890123) in order to avoid floating point and reduce size.

### Miscellaneous

- Removed APIs deprecated in 7.x, per our policy.
- The default job error logging now provides more detail in INFO and the full backtrace in DEBUG.

Expand Down
10 changes: 5 additions & 5 deletions lib/active_job/queue_adapters/sidekiq_adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def perform(job_data)

module ActiveJob
module QueueAdapters
# Explicitly remove the implementation existing in older rails'.
# Explicitly remove the implementation existing in older Rails.
remove_const(:SidekiqAdapter) if const_defined?(:SidekiqAdapter)

# Sidekiq adapter for Active Job
Expand All @@ -33,15 +33,15 @@ def enqueue_after_transaction_commit?

# @api private
def enqueue(job)
job.provider_job_id = JobWrapper.set(
job.provider_job_id = Sidekiq::ActiveJob::Wrapper.set(
wrapped: job.class,
queue: job.queue_name
).perform_async(job.serialize)
end

# @api private
def enqueue_at(job, timestamp)
job.provider_job_id = JobWrapper.set(
job.provider_job_id = Sidekiq::ActiveJob::Wrapper.set(
wrapped: job.class,
queue: job.queue_name
).perform_at(timestamp, job.serialize)
Expand All @@ -56,7 +56,7 @@ def enqueue_all(jobs)

if immediate_jobs.any?
jids = Sidekiq::Client.push_bulk(
"class" => JobWrapper,
"class" => Sidekiq::ActiveJob::Wrapper,
"wrapped" => job_class,
"queue" => queue,
"args" => immediate_jobs.map { |job| [job.serialize] }
Expand All @@ -66,7 +66,7 @@ def enqueue_all(jobs)

if scheduled_jobs.any?
jids = Sidekiq::Client.push_bulk(
"class" => JobWrapper,
"class" => Sidekiq::ActiveJob::Wrapper,
"wrapped" => job_class,
"queue" => queue,
"args" => scheduled_jobs.map { |job| [job.serialize] },
Expand Down
4 changes: 2 additions & 2 deletions test/active_job_adapter_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def perform(arg1, arg2)
assert_equal 24, instance.provider_job_id.size

job = q.first
assert_equal "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper", job["class"]
assert_equal "Sidekiq::ActiveJob::Wrapper", job["class"]
assert_equal "AjJob", job["wrapped"]
end

Expand All @@ -63,7 +63,7 @@ def perform(arg1, arg2)

job = ss.find_job(instance.provider_job_id)
assert_equal "default", job["queue"]
assert_equal "ActiveJob::QueueAdapters::SidekiqAdapter::JobWrapper", job["class"]
assert_equal "Sidekiq::ActiveJob::Wrapper", job["class"]
assert_equal "AjJob", job["wrapped"]
end

Expand Down

0 comments on commit 4d80a26

Please sign in to comment.