Class: Maxwell::Agent::Scheduler

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/maxwell/agent/scheduler.rb

Instance Method Summary collapse

Constructor Details

#initializeScheduler

Returns a new instance of Scheduler.



6
7
8
# File 'lib/maxwell/agent/scheduler.rb', line 6

def initialize
  async.run
end

Instance Method Details

#runObject



14
15
16
17
18
19
# File 'lib/maxwell/agent/scheduler.rb', line 14

def run
  loop do
    sleep Maxwell.configuration.work_poll
    schedule_work
  end
end

#runnerObject



30
31
32
# File 'lib/maxwell/agent/scheduler.rb', line 30

def runner
  links.detect {|link| Celluloid::SupervisionGroup === link }
end

#schedule_workObject



21
22
23
24
# File 'lib/maxwell/agent/scheduler.rb', line 21

def schedule_work
  work = work_schedule.get
  worker.async.perform(work) if work
end

#work_scheduleObject



10
11
12
# File 'lib/maxwell/agent/scheduler.rb', line 10

def work_schedule
  runner[:work_schedule]
end

#workerObject



26
27
28
# File 'lib/maxwell/agent/scheduler.rb', line 26

def worker
  runner[:worker]
end