Class: Qwirk::AdapterFactory
- Inherits:
-
Object
- Object
- Qwirk::AdapterFactory
- Includes:
- Rumx::Bean
- Defined in:
- lib/qwirk/adapter_factory.rb
Overview
Defines the queuing adapter. Currently, only JMS and InMemory.
Constant Summary collapse
- @@adapter_hash =
{}
Instance Attribute Summary collapse
-
#adapter_info ⇒ Object
readonly
Returns the value of attribute adapter_info.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#log_times ⇒ Object
readonly
Returns the value of attribute log_times.
-
#manager ⇒ Object
readonly
Returns the value of attribute manager.
-
#worker_config_class ⇒ Object
readonly
Returns the value of attribute worker_config_class.
Class Method Summary collapse
-
.register(key, publisher_class, worker_config_class, &block) ⇒ Object
Register an adapter by passing in a publisher_class, a worker_config_class and optionally a code block.
Instance Method Summary collapse
- #create_manager(options = {}) ⇒ Object
- #create_publisher(options = {}) ⇒ Object
- #create_publisher_impl(queue_name, topic_name, options, response_options) ⇒ Object
- #in_process? ⇒ Boolean
-
#initialize(key, config) ⇒ AdapterFactory
constructor
A new instance of AdapterFactory.
- #remote=(remote_options) ⇒ Object
Constructor Details
#initialize(key, config) ⇒ AdapterFactory
Returns a new instance of AdapterFactory.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/qwirk/adapter_factory.rb', line 18 def initialize(key, config) @key = key @config = config.dup @log_times = config.delete(:log_times) key = config.delete(:adapter) raise "No adapter definition config=#{config.inspect}" unless key key = key.to_sym @publisher_class, @worker_config_class, block = @@adapter_hash[key] raise "No adapter matching #{key}" unless @publisher_class self.remote = config.delete(:remote) @adapter_info = block.call(config) if block end |
Instance Attribute Details
#adapter_info ⇒ Object (readonly)
Returns the value of attribute adapter_info.
7 8 9 |
# File 'lib/qwirk/adapter_factory.rb', line 7 def adapter_info @adapter_info end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
7 8 9 |
# File 'lib/qwirk/adapter_factory.rb', line 7 def config @config end |
#key ⇒ Object (readonly)
Returns the value of attribute key.
7 8 9 |
# File 'lib/qwirk/adapter_factory.rb', line 7 def key @key end |
#log_times ⇒ Object (readonly)
Returns the value of attribute log_times.
7 8 9 |
# File 'lib/qwirk/adapter_factory.rb', line 7 def log_times @log_times end |
#manager ⇒ Object (readonly)
Returns the value of attribute manager.
7 8 9 |
# File 'lib/qwirk/adapter_factory.rb', line 7 def manager @manager end |
#worker_config_class ⇒ Object (readonly)
Returns the value of attribute worker_config_class.
7 8 9 |
# File 'lib/qwirk/adapter_factory.rb', line 7 def worker_config_class @worker_config_class end |
Class Method Details
.register(key, publisher_class, worker_config_class, &block) ⇒ Object
Register an adapter by passing in a publisher_class, a worker_config_class and optionally a code block. The code block will expect a config object as it’s argument and will return connection information or any other client_information required for this adapter.
14 15 16 |
# File 'lib/qwirk/adapter_factory.rb', line 14 def self.register(key, publisher_class, worker_config_class, &block) @@adapter_hash[key] = [publisher_class, worker_config_class, block] end |
Instance Method Details
#create_manager(options = {}) ⇒ Object
39 40 41 42 43 |
# File 'lib/qwirk/adapter_factory.rb', line 39 def create_manager(={}) @manager = Manager.new(self, @config.merge()) bean_add_child(:Workers, @manager) return @manager end |
#create_publisher(options = {}) ⇒ Object
32 33 34 35 36 37 |
# File 'lib/qwirk/adapter_factory.rb', line 32 def create_publisher(={}) @publisher_parent ||= ::Rumx::Beans::Folder.new publisher = Publisher.new(self, @config.merge()) @publisher_parent.bean_add_child(publisher.to_s, publisher) return publisher end |
#create_publisher_impl(queue_name, topic_name, options, response_options) ⇒ Object
45 46 47 |
# File 'lib/qwirk/adapter_factory.rb', line 45 def create_publisher_impl(queue_name, topic_name, , ) @publisher_class.new(self, queue_name, topic_name, , ) end |
#in_process? ⇒ Boolean
49 50 51 |
# File 'lib/qwirk/adapter_factory.rb', line 49 def in_process? @worker_config_class.in_process?(@config) end |