lib/basquiat/adapters/base_adapter.rb in basquiat-1.3.0.pre.1 vs lib/basquiat/adapters/base_adapter.rb in basquiat-1.3.0
- old
+ new
@@ -1,11 +1,12 @@
+# frozen_string_literal: true
require 'delegate'
require 'basquiat/adapters/base_message'
module Basquiat
module Adapters
- # Base implementation for an adapter
+ # Base implementation for an adapter in uses {HashRefinements} internally.
class Base
using Basquiat::HashRefinements
class << self
# A hash representing the registered requeue/acknowledge strategies
@@ -19,22 +20,22 @@
# @param klass [Class] the class name.
def register_strategy(config_name, klass)
strategies[config_name.to_sym] = klass
end
- # Return the Strategy Class registered on key
+ # Return the Strategy Class registered on given key
# @param key [#to_sym] configured key for the wanted strategy
- # @return [Class] return the strategy class
+ # @return [Class] the strategy class
# @raise [Errors::StrategyNotRegistered] if it fails to find the key
def strategy(key)
strategies.fetch(key)
rescue KeyError
raise Basquiat::Errors::StrategyNotRegistered
end
end
- # @param procs: [Object]
+ # @param procs [Object]
# It's a hash by default, but usually will be superseded by the adapter implementation
def initialize(procs: {})
@options = base_options
@procs = procs
@retries = 0
@@ -59,12 +60,13 @@
def adapter_options(opts)
@options.deep_merge(opts)
end
# The default adapter options, merged with the {Basquiat::Configuration#adapter_options}. Used internally.
- # @todo rename this method
+ # @api private
# @return [Hash] the full options hash
+ # @todo rename this method
def base_options
default_options.merge(Basquiat.configuration.adapter_options)
end
# The adapter default options
@@ -74,22 +76,21 @@
end
# @!group Adapter specific implementations
# @abstract Publish an event to the event stream
def publish
- fail Basquiat::Errors::SubclassResponsibility
+ raise Basquiat::Errors::SubclassResponsibility
end
# @abstract subscribe_to the event stream
def subscribe_to
- fail Basquiat::Errors::SubclassResponsibility
+ raise Basquiat::Errors::SubclassResponsibility
end
# @abstract Disconnect from the message queue
def disconnect
- fail Basquiat::Errors::SubclassResponsibility
+ raise Basquiat::Errors::SubclassResponsibility
end
-
# @!endgroup
private
attr_reader :procs, :options