class GorgService::Consumer

Attributes

environment[RW]

Public Class Methods

new(environment: GorgService.environment) click to toggle source
# File lib/gorg_service/consumer.rb, line 14
def initialize(environment: GorgService.environment)
  @environment=environment
end

Public Instance Methods

listener() click to toggle source
# File lib/gorg_service/consumer.rb, line 18
def listener
  @listener ||= Listener.new(
      env: environment,
      max_attempts: GorgService.configuration.rabbitmq_max_attempts.to_i,
      log_routing_key: GorgService.configuration.log_routing_key
  )
end
run() click to toggle source
# File lib/gorg_service/consumer.rb, line 26
def run
  begin
    self.start
    puts " [*] Waiting for messages. To exit press CTRL+C"
    loop do
      sleep(1)
    end
  rescue SystemExit, Interrupt => _
    self.stop
  end
end
start() click to toggle source
# File lib/gorg_service/consumer.rb, line 38
def start
  listener.listen
end
stop() click to toggle source
# File lib/gorg_service/consumer.rb, line 42
def stop
  listener.stop
end