Module: Rabbit::Daemon

Extended by:
Daemon
Included in:
Daemon
Defined in:
lib/rabbit/daemon.rb

Instance Method Summary collapse

Instance Method Details

#configObject



29
30
31
# File 'lib/rabbit/daemon.rb', line 29

def config
  Rails.application.config_for("sneakers").symbolize_keys
end

#connectionObject



33
34
35
36
# File 'lib/rabbit/daemon.rb', line 33

def connection
  bunny_config = config.delete(:bunny_options).to_h.symbolize_keys
  Bunny.new(bunny_config)
end

#run(logger: Sneakers.logger) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/rabbit/daemon.rb', line 14

def run(logger: Sneakers.logger)
  unless logger
    logger = Logger.new(Rails.root.join("log", "sneakers.log"))
    logger.level = Logger::DEBUG
    Lamian.extend_logger(logger)
  end

  Sneakers.configure(**sneakers_config(logger: logger))
  Sneakers.server = true

  Rabbit.config.validate!
  Receiving::Worker.from_queue(Rabbit.config.read_queue)
  Sneakers::Runner.new([Receiving::Worker]).run
end