Skip to content

Commit

Permalink
Default to 0 (until v1.0) and document in README
Browse files Browse the repository at this point in the history
  • Loading branch information
smudge committed Dec 18, 2024
1 parent f8ac334 commit 200beb5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,10 @@ Delayed::Worker.read_ahead = 5

# If a worker finds no jobs, it will sleep this number of seconds in between attempts:
Delayed::Worker.sleep_delay = 5

# Until version 1.0, the worker will not sleep at all between attemps if it finds jobs.
# This can be configured by setting the minimum reserve interval:
Delayed::Worker.min_reserve_interval = 0.5 # seconds
```

If a job fails, it will be rerun up to 25 times (with an exponential back-off). Jobs will also
Expand Down
2 changes: 1 addition & 1 deletion lib/delayed/worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class Worker
include Runnable

cattr_accessor :sleep_delay, instance_writer: false, default: 5
cattr_accessor :min_reserve_interval, instance_writer: false, default: 1
cattr_accessor :min_reserve_interval, instance_writer: false, default: 0
cattr_accessor :max_attempts, instance_writer: false, default: 25
cattr_accessor :max_claims, instance_writer: false, default: 5
cattr_accessor :max_run_time, instance_writer: false, default: 20.minutes
Expand Down
4 changes: 4 additions & 0 deletions spec/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ class SingletonClass
sleep_delay_was = Delayed::Worker.sleep_delay
min_reserve_interval_was = Delayed::Worker.min_reserve_interval

if Gem.loaded_specs['delayed'].version >= Gem::Version.new('1.0') && min_reserve_interval_was.zero?
raise "Min reserve interval should be nonzero in v1.0 release"
end

Delayed::Worker.sleep_delay = TEST_SLEEP_DELAY
Delayed::Worker.min_reserve_interval = TEST_MIN_RESERVE_INTERVAL

Expand Down

0 comments on commit 200beb5

Please sign in to comment.