Class: Maxwell::Agent::Scheduler
- Inherits:
-
Object
- Object
- Maxwell::Agent::Scheduler
- Includes:
- Celluloid
- Defined in:
- lib/maxwell/agent/scheduler.rb
Instance Attribute Summary collapse
-
#evented_worker ⇒ Object
readonly
Returns the value of attribute evented_worker.
-
#worder ⇒ Object
readonly
Returns the value of attribute worder.
-
#work_schedule ⇒ Object
readonly
Returns the value of attribute work_schedule.
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ Scheduler
constructor
A new instance of Scheduler.
- #run ⇒ Object
- #schedule_work ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Scheduler
Returns a new instance of Scheduler.
8 9 10 11 12 |
# File 'lib/maxwell/agent/scheduler.rb', line 8 def initialize(opts={}) @work_schedule ||= opts.fetch(:work_schedule) @evented_worker ||= opts.fetch(:evented_worker) @worker ||= opts.fetch(:worker) end |
Instance Attribute Details
#evented_worker ⇒ Object (readonly)
Returns the value of attribute evented_worker.
6 7 8 |
# File 'lib/maxwell/agent/scheduler.rb', line 6 def evented_worker @evented_worker end |
#worder ⇒ Object (readonly)
Returns the value of attribute worder.
6 7 8 |
# File 'lib/maxwell/agent/scheduler.rb', line 6 def worder @worder end |
#work_schedule ⇒ Object (readonly)
Returns the value of attribute work_schedule.
6 7 8 |
# File 'lib/maxwell/agent/scheduler.rb', line 6 def work_schedule @work_schedule end |
Instance Method Details
#run ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/maxwell/agent/scheduler.rb', line 14 def run set_links loop do sleep Agent.configuration.work_poll schedule_work end end |
#schedule_work ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/maxwell/agent/scheduler.rb', line 22 def schedule_work if work = work_schedule.get if work.evented? evented_worker.async.perform(work) else worker.async.perform(work) end end end |