class Basquiat::Adapters::RabbitMq::Configuration
Responsible for dealing with the overall configuration of the RabbitMQ adapter
Public Class Methods
new()
click to toggle source
# File lib/basquiat/adapters/rabbitmq/configuration.rb, line 10 def initialize @options = { connection: { hosts: ['localhost'], port: 5672, auth: { user: 'guest', password: 'guest' } }, queue: { name: Basquiat.configuration.queue_name, durable: true, options: {} }, exchange: { name: Basquiat.configuration.exchange_name, durable: true, options: {} }, publisher: { confirm: true, persistent: false }, consumer: { prefetch: 1000, manual_ack: true }, requeue: { enabled: false } } end
Public Instance Methods
base_options()
click to toggle source
# File lib/basquiat/adapters/rabbitmq/configuration.rb, line 30 def base_options @options end
connection_options()
click to toggle source
@return [Hash] the connection options
# File lib/basquiat/adapters/rabbitmq/configuration.rb, line 47 def connection_options @options[:connection] end
merge_user_options(**user_opts)
click to toggle source
Merges the user supplied options with the base ones @param user_opts [Hash{Symbol=>Object}] @option user_opts [Hash{Symbol=>Object}] :connection see {Connection#initialize} @option user_opts [Hash{Symbol=>Object}] :queue @option user_opts [Hash{Symbol=>Object}] :exchange @option user_opts [Hash{Symbol=>Object}] :publisher @option user_opts [Hash{Symbol=>Object}] :requeue @return [Hash] the configuration option hash
# File lib/basquiat/adapters/rabbitmq/configuration.rb, line 42 def merge_user_options(**user_opts) @options.deep_merge(user_opts) end
session_options()
click to toggle source
@return [Hash] the session options
# File lib/basquiat/adapters/rabbitmq/configuration.rb, line 52 def session_options { exchange: @options[:exchange], publisher: @options[:publisher], consumer: @options[:consumer], queue: @options[:queue] }.deep_merge(strategy.session_options) end
strategy()
click to toggle source
@return [BaseStrategy] the requeue strategy or {BasicAcknowledge} if none is configured
# File lib/basquiat/adapters/rabbitmq/configuration.rb, line 60 def strategy requeue = @options[:requeue] return AutoAcknowledge unless requeue[:enabled] @strategy ||= RabbitMq.strategy(requeue[:strategy].to_sym) @strategy.setup(requeue[:options] || {}) @strategy end