Class: Async::Background::Entry
- Inherits:
-
Object
- Object
- Async::Background::Entry
- Defined in:
- lib/async/background/entry.rb
Instance Attribute Summary collapse
-
#cron ⇒ Object
readonly
Returns the value of attribute cron.
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#job_class ⇒ Object
readonly
Returns the value of attribute job_class.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#next_run_at ⇒ Object
Returns the value of attribute next_run_at.
-
#running ⇒ Object
Returns the value of attribute running.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#initialize(name:, job_class:, interval:, cron:, timeout:, next_run_at:) ⇒ Entry
constructor
A new instance of Entry.
- #reschedule(monotonic_now) ⇒ Object
Constructor Details
#initialize(name:, job_class:, interval:, cron:, timeout:, next_run_at:) ⇒ Entry
Returns a new instance of Entry.
9 10 11 12 13 14 15 16 17 |
# File 'lib/async/background/entry.rb', line 9 def initialize(name:, job_class:, interval:, cron:, timeout:, next_run_at:) @name = name @job_class = job_class @interval = interval @cron = cron @timeout = timeout @next_run_at = next_run_at @running = false end |
Instance Attribute Details
#cron ⇒ Object (readonly)
Returns the value of attribute cron.
6 7 8 |
# File 'lib/async/background/entry.rb', line 6 def cron @cron end |
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
6 7 8 |
# File 'lib/async/background/entry.rb', line 6 def interval @interval end |
#job_class ⇒ Object (readonly)
Returns the value of attribute job_class.
6 7 8 |
# File 'lib/async/background/entry.rb', line 6 def job_class @job_class end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/async/background/entry.rb', line 6 def name @name end |
#next_run_at ⇒ Object
Returns the value of attribute next_run_at.
7 8 9 |
# File 'lib/async/background/entry.rb', line 7 def next_run_at @next_run_at end |
#running ⇒ Object
Returns the value of attribute running.
7 8 9 |
# File 'lib/async/background/entry.rb', line 7 def running @running end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
6 7 8 |
# File 'lib/async/background/entry.rb', line 6 def timeout @timeout end |
Instance Method Details
#reschedule(monotonic_now) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/async/background/entry.rb', line 19 def reschedule(monotonic_now) if interval @next_run_at += interval @next_run_at = monotonic_now + interval if @next_run_at <= monotonic_now else now_wall = Time.now wait = cron.next_time(now_wall).to_f - now_wall.to_f @next_run_at = monotonic_now + [wait, Async::Background::MIN_SLEEP_TIME].max end end |