Module: AMQP::Boilerplate::ConsumerRegistry

Included in:
AMQP::Boilerplate
Defined in:
lib/amqp/boilerplate/consumer_registry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#consumer_pathsObject

Returns an array of paths which files are loaded when AMQP::Boilerplate.boot is called. You should define the consumer_paths when you configure AMQP::Boilerplate and assign an array of paths pointing to the folder where your consumer files are located, to it.



11
12
13
# File 'lib/amqp/boilerplate/consumer_registry.rb', line 11

def consumer_paths
  @consumer_paths ||= []
end

Instance Method Details

#load_consumersObject



15
16
17
18
19
# File 'lib/amqp/boilerplate/consumer_registry.rb', line 15

def load_consumers
  consumer_paths.each do |dir|
    Dir[File.join(dir, "*.rb")].each {|f| require f}
  end
end

#register_consumer(klass) ⇒ Object



25
26
27
28
# File 'lib/amqp/boilerplate/consumer_registry.rb', line 25

def register_consumer(klass)
  AMQP::Boilerplate.logger.info("[#{self.name}#register_consumer] Registered consumer '#{klass.name}'")
  registry << klass
end

#registryObject



21
22
23
# File 'lib/amqp/boilerplate/consumer_registry.rb', line 21

def registry
  @registry ||= []
end

#start_consumersObject



30
31
32
33
34
# File 'lib/amqp/boilerplate/consumer_registry.rb', line 30

def start_consumers
  registry.each do |consumer|
    consumer.start
  end
end