Class: Peplum::Application::Services::Scheduler

Inherits:
Object
  • Object
show all
Defined in:
lib/peplum/application/services/scheduler.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.agentObject



30
31
32
# File 'lib/peplum/application/services/scheduler.rb', line 30

def agent
  @agent ||= Processes::Agents.connect( Cuboid::Options.agent.url )
end

.doneObject



26
27
28
# File 'lib/peplum/application/services/scheduler.rb', line 26

def done
  self.done_signal << nil
end

.done_signalObject



18
19
20
# File 'lib/peplum/application/services/scheduler.rb', line 18

def done_signal
  @done_signal ||= Queue.new
end

.get_workerObject



9
10
11
12
13
14
15
16
# File 'lib/peplum/application/services/scheduler.rb', line 9

def get_worker
  worker_info = agent.spawn
  return if !worker_info

  worker = Peplum::Application.connect( worker_info )
  self.workers[worker.url] = worker
  worker
end

.waitObject



22
23
24
# File 'lib/peplum/application/services/scheduler.rb', line 22

def wait
  self.done_signal.pop
end

.workersObject



34
35
36
# File 'lib/peplum/application/services/scheduler.rb', line 34

def workers
  @workers ||= {}
end

Instance Method Details

#report(data, url) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/peplum/application/services/scheduler.rb', line 39

def report( data, url )
  return if !(worker = self.class.workers.delete( url ))

  report_data << data

  worker.shutdown {}
  return unless self.class.workers.empty?

  Cuboid::Application.application.report report_data

  self.class.done
end