Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don’t attempt to enforce concurrency limits with other queue adapters #333

Merged
merged 1 commit into from
Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/good_job/active_job_extensions/concurrency.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ module Concurrency
class_attribute :good_job_concurrency_config, instance_accessor: false, default: {}

around_enqueue do |job, block|
# Don't attempt to enforce concurrency limits with other queue adapters.
next(block.call) unless job.class.queue_adapter.is_a?(GoodJob::Adapter)

# Always allow jobs to be retried because the current job's execution will complete momentarily
next(block.call) if CurrentExecution.active_job_id == job.job_id

Expand All @@ -34,6 +37,9 @@ module Concurrency
)

before_perform do |job|
# Don't attempt to enforce concurrency limits with other queue adapters.
next unless job.class.queue_adapter.is_a?(GoodJob::Adapter)

limit = job.class.good_job_concurrency_config.fetch(:perform_limit, Float::INFINITY)
next if limit.blank? || (0...Float::INFINITY).exclude?(limit)

Expand Down