Class: Basquiat::Adapters::Base
- Inherits:
-
Object
- Object
- Basquiat::Adapters::Base
- Defined in:
- lib/basquiat/adapters/base_adapter.rb
Overview
Base implementation for an adapter in uses HashRefinements internally.
Instance Attribute Summary collapse
-
#procs ⇒ Object
readonly
Returns the value of attribute procs.
Adapter specific implementations collapse
- #disconnect ⇒ Object abstract
- #publish ⇒ Object abstract
- #subscribe_to ⇒ Object abstract
Class Method Summary collapse
-
.register_strategy(config_name, klass) ⇒ Object
Used to register a requeue/acknowledge strategy.
-
.strategies ⇒ Hash
A hash representing the registered requeue/acknowledge strategies.
-
.strategy(key) ⇒ Class
Return the Strategy Class registered on given key.
Instance Method Summary collapse
-
#adapter_options(opts) ⇒ Object
Allows the #base_options to be superseded on the local level.
-
#base_options ⇒ Hash
private
The default adapter options, merged with the Configuration#adapter_options.
-
#default_options ⇒ Hash
The adapter default options.
-
#initialize(procs: {}) ⇒ Base
constructor
A new instance of Base.
-
#strategies ⇒ Object
Utility method to access the class instance variable.
Constructor Details
#initialize(procs: {}) ⇒ Base
Returns a new instance of Base.
39 40 41 42 43 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 39 def initialize(procs: {}) @options = @procs = procs @retries = 0 end |
Instance Attribute Details
#procs ⇒ Object (readonly)
Returns the value of attribute procs.
96 97 98 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 96 def procs @procs end |
Class Method Details
.register_strategy(config_name, klass) ⇒ Object
Used to register a requeue/acknowledge strategy
22 23 24 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 22 def register_strategy(config_name, klass) strategies[config_name.to_sym] = klass end |
.strategies ⇒ Hash
A hash representing the registered requeue/acknowledge strategies
15 16 17 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 15 def strategies @strategies ||= {} end |
.strategy(key) ⇒ Class
Return the Strategy Class registered on given key
30 31 32 33 34 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 30 def strategy(key) strategies.fetch(key) rescue KeyError raise Basquiat::Errors::StrategyNotRegistered end |
Instance Method Details
#adapter_options(opts) ⇒ Object
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.
61 62 63 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 61 def (opts) @options.deep_merge(opts) end |
#base_options ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
rename this method
The default adapter options, merged with the Configuration#adapter_options. Used internally.
69 70 71 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 69 def .merge(Basquiat.configuration.) end |
#default_options ⇒ Hash
The adapter default options
75 76 77 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 75 def {} end |
#disconnect ⇒ Object
Disconnect from the message queue
91 92 93 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 91 def disconnect raise Basquiat::Errors::SubclassResponsibility end |
#publish ⇒ Object
Publish an event to the event stream
81 82 83 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 81 def publish raise Basquiat::Errors::SubclassResponsibility end |
#strategies ⇒ Object
Utility method to access the class instance variable
46 47 48 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 46 def strategies self.class.strategies end |
#subscribe_to ⇒ Object
subscribe_to the event stream
86 87 88 |
# File 'lib/basquiat/adapters/base_adapter.rb', line 86 def subscribe_to raise Basquiat::Errors::SubclassResponsibility end |