Class: Primer::Worker

Inherits:
Object
  • Object
show all
Defined in:
lib/primer/worker.rb,
lib/primer/worker/changes_agent.rb,
lib/primer/worker/active_record_agent.rb

Defined Under Namespace

Classes: ActiveRecordAgent, Agent, ChangesAgent, ConfigError

Instance Method Summary collapse

Instance Method Details

#run!Object

Raises:



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/primer/worker.rb', line 25

def run!
  raise ConfigError.new('No cache present') unless Primer.cache
  raise ConfigError.new('No message bus present') unless Primer.bus
  
  puts "Cache: #{ Primer.cache }"
  puts "Message bus: #{ Primer.bus }"
  puts
  
  EM.run {
    Primer.bus.subscribe :active_record do |args|
      puts "[active_record] #{ args.inspect }"
    end
    Primer.bus.subscribe :changes do |args|
      puts "[changes] #{ args.inspect }"
    end
    
    ActiveRecordAgent.run!
    ChangesAgent.run!
    
    puts "Listening for messages..."
    puts
  }
end