class PikaQue::Configuration

Constants

CHANNEL_OPTION_DEFAULTS
DEFAULT_CONFIG
DELAY_PROCESSOR_DEFAULTS
EXCHANGE_OPTION_DEFAULTS
QUEUE_OPTION_DEFAULTS

Public Class Methods

new() click to toggle source

processor example @processor Processor class @workers array of worker classes @connection connection params if using separate connection {

:processor          => Processor,
:connection_options => {},
:workers            => [],
:concurrency        => 1,
:ack                => true,
:handler_class      => nil,
:handler_options    => {},
:codec              => PikaQue::Codecs::JSON

}

# File lib/pika_que/configuration.rb, line 79
def initialize
  @config = Marshal.load(Marshal.dump(DEFAULT_CONFIG))
  @config[:amqp]  = ENV.fetch('RABBITMQ_URL', 'amqp://guest:guest@localhost:5672')
  @config[:vhost] = AMQ::Settings.parse_amqp_url(@config[:amqp]).fetch(:vhost, '/')
end

Public Instance Methods

deep_merge(first, second) click to toggle source
# File lib/pika_que/configuration.rb, line 102
def deep_merge(first, second)
  merger = proc { |_, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
  first.merge(second, &merger)
end
load(filename) click to toggle source
# File lib/pika_que/configuration.rb, line 85
def load(filename)
  loaded = YAML.load_file(filename)
  converted = JSON.parse(JSON.dump(loaded), symbolize_names: true)
  merge! converted
end
merge(other = {}) click to toggle source
# File lib/pika_que/configuration.rb, line 95
def merge(other = {})
  instance = self.class.new
  instance.merge! to_hash
  instance.merge! other
  instance
end
merge!(other = {}) click to toggle source
# File lib/pika_que/configuration.rb, line 91
def merge!(other = {})
  @config = deep_merge(@config, other)
end