Class: Peplum::Application::Services::Scheduler
- Inherits:
-
Object
- Object
- Peplum::Application::Services::Scheduler
- Defined in:
- lib/peplum/application/services/scheduler.rb
Class Method Summary collapse
- .agent ⇒ Object
- .done ⇒ Object
- .done_signal ⇒ Object
- .get_worker ⇒ Object
- .wait ⇒ Object
- .workers ⇒ Object
Instance Method Summary collapse
Class Method Details
.agent ⇒ Object
30 31 32 |
# File 'lib/peplum/application/services/scheduler.rb', line 30 def agent @agent ||= Processes::Agents.connect( Cuboid::Options.agent.url ) end |
.done ⇒ Object
26 27 28 |
# File 'lib/peplum/application/services/scheduler.rb', line 26 def done self.done_signal << nil end |
.done_signal ⇒ Object
18 19 20 |
# File 'lib/peplum/application/services/scheduler.rb', line 18 def done_signal @done_signal ||= Queue.new end |
.get_worker ⇒ Object
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 |
.wait ⇒ Object
22 23 24 |
# File 'lib/peplum/application/services/scheduler.rb', line 22 def wait self.done_signal.pop end |
.workers ⇒ Object
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 |