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

Refactor deprecated wait parameter and assorted improvements #249

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
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: 3 additions & 3 deletions lib/good_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ def self.reperform_jobs_on_standard_error=(value)
# @param wait [Boolean] whether to wait for shutdown
# @return [void]
def self.shutdown(timeout: -1, wait: nil)
timeout = if wait.present?
timeout = if wait.nil?
timeout
else
ActiveSupport::Deprecation.warn(
"Using `GoodJob.shutdown` with `wait:` kwarg is deprecated; use `timeout:` kwarg instead e.g. GoodJob.shutdown(timeout: #{wait ? '-1' : 'nil'})"
)
wait ? -1 : nil
else
timeout
end

executables = Array(Notifier.instances) + Array(Poller.instances) + Array(Scheduler.instances)
Expand Down
6 changes: 3 additions & 3 deletions lib/good_job/adapter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,13 @@ def enqueue_at(active_job, timestamp)
# @param wait [Boolean, nil] Deprecated. Use +timeout:+ instead.
# @return [void]
def shutdown(timeout: :default, wait: nil)
timeout = if wait.present?
timeout = if wait.nil?
timeout
else
ActiveSupport::Deprecation.warn(
"Using `GoodJob::Adapter.shutdown` with `wait:` kwarg is deprecated; use `timeout:` kwarg instead e.g. GoodJob::Adapter.shutdown(timeout: #{wait ? '-1' : 'nil'})"
)
wait ? -1 : nil
else
timeout
end

timeout = if timeout == :default
Expand Down
6 changes: 3 additions & 3 deletions lib/good_job/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ def max_threads
# on the format of this string.
# @return [String]
def queue_string
options[:queues] ||
rails_config[:queues] ||
env['GOOD_JOB_QUEUES'] ||
options[:queues].presence ||
rails_config[:queues].presence ||
env['GOOD_JOB_QUEUES'].presence ||
'*'
end

Expand Down
4 changes: 2 additions & 2 deletions scripts/benchmark_scheduler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
MAX_THREADS = 0
JOBS_SIZE = 20_000

class Performer
class CustomPerformer < GoodJob::JobPerformer
def name
'script'
end
Expand All @@ -28,7 +28,7 @@ def next_at(**_options)
end
end

scheduler = GoodJob::Scheduler.new(Performer.new, max_threads: MAX_THREADS, max_cache: MAX_CACHE)
scheduler = GoodJob::Scheduler.new(CustomPerformer.new("*"), max_threads: MAX_THREADS, max_cache: MAX_CACHE)

report = MemoryProfiler.report do
JOBS_SIZE.times { scheduler.create_thread({ scheduled_at: Time.current + 100_000 }) }
Expand Down