class Basquiat::Adapters::Base
Base
implementation for an adapter in uses {HashRefinements} internally.
Attributes
@!endgroup
Public Class Methods
@param procs [Object]
It's a hash by default, but usually will be superseded by the adapter implementation
# File lib/basquiat/adapters/base_adapter.rb, line 39 def initialize(procs: {}) @options = base_options @procs = procs @retries = 0 end
Used to register a requeue/acknowledge strategy @param config_name [#to_sym] the named used on the config file for the Requeue Strategy @param klass [Class] the class name.
# File lib/basquiat/adapters/base_adapter.rb, line 22 def register_strategy(config_name, klass) strategies[config_name.to_sym] = klass end
A hash representing the registered requeue/acknowledge strategies @return [Hash] the registered RequeueStrategies
# File lib/basquiat/adapters/base_adapter.rb, line 15 def strategies @strategies ||= {} end
Return the Strategy Class registered on given key @param key [#to_sym] configured key for the wanted strategy @return [Class] the strategy class @raise [Errors::StrategyNotRegistered] if it fails to find the key
# File lib/basquiat/adapters/base_adapter.rb, line 30 def strategy(key) strategies.fetch(key) rescue KeyError raise Basquiat::Errors::StrategyNotRegistered end
Public Instance Methods
Allows the base_options
to be superseded on the local level
You could have configured an exchange_name (on a config file) to +'awesome.sauce'+, but on this object you'd want to publish your messages to the +'killer.mailman'+ exchange. @example
class Mailmail extend Basquiat::Base adapter_options {exchange: {name: 'killer.mailman'}} end
@param [Hash] opts an adapter dependant hash of options
# File lib/basquiat/adapters/base_adapter.rb, line 61 def adapter_options(opts) @options.deep_merge(opts) end
The default adapter options, merged with the {Basquiat::Configuration#adapter_options}. Used internally. @api private @return [Hash] the full options hash @todo rename this method
# File lib/basquiat/adapters/base_adapter.rb, line 69 def base_options default_options.merge(Basquiat.configuration.adapter_options) end
The adapter default options @return [Hash]
# File lib/basquiat/adapters/base_adapter.rb, line 75 def default_options {} end
@abstract Disconnect from the message queue
# File lib/basquiat/adapters/base_adapter.rb, line 91 def disconnect raise Basquiat::Errors::SubclassResponsibility end
@!group Adapter specific implementations @abstract Publish an event to the event stream
# File lib/basquiat/adapters/base_adapter.rb, line 81 def publish raise Basquiat::Errors::SubclassResponsibility end
Utility method to access the class instance variable
# File lib/basquiat/adapters/base_adapter.rb, line 46 def strategies self.class.strategies end
@abstract subscribe_to
the event stream
# File lib/basquiat/adapters/base_adapter.rb, line 86 def subscribe_to raise Basquiat::Errors::SubclassResponsibility end