Class: Mimi::Messaging::Adapters::Memory
- Defined in:
- lib/mimi/messaging/adapters/memory.rb
Overview
A Memory is an in-memory implementation of a messaging adapter.
All message dispatching happens within a single thread, the same as the caller’s, so all ivocations are synchronous.
The Memory purpose is only to use in tests and for the higher abstractions development.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#command(target, message, opts = {}) ⇒ Object
Sends COMMAND to target.
-
#event(target, message, opts = {}) ⇒ Object
Sends EVENT to target.
-
#query(target, message, opts = {}) ⇒ Object
Sends QUERY to target.
- #start ⇒ Object
- #start_event_processor(topic_name, processor, _opts = {}) ⇒ Object
- #start_event_processor_with_queue(topic_name, queue_name, processor, opts = {}) ⇒ Object
- #start_request_processor(queue_name, processor, _opts = {}) ⇒ Object
- #stop ⇒ Object
- #stop_all_processors ⇒ Object
Methods inherited from Base
#initialize, register_adapter_name, #register_message_serializer
Constructor Details
This class inherits a constructor from Mimi::Messaging::Adapters::Base
Instance Method Details
#command(target, message, opts = {}) ⇒ Object
Sends COMMAND to target
32 33 34 35 36 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 32 def command(target, , opts = {}) raise ArgumentError, "Message is expected" unless .is_a?(Mimi::Messaging::Message) dispatch_command(target, , opts) nil end |
#event(target, message, opts = {}) ⇒ Object
Sends EVENT to target
56 57 58 59 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 56 def event(target, , opts = {}) raise ArgumentError, "Message is expected" unless .is_a?(Mimi::Messaging::Message) dispatch_event(target, , opts) end |
#query(target, message, opts = {}) ⇒ Object
Sends QUERY to target
44 45 46 47 48 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 44 def query(target, , opts = {}) raise ArgumentError, "Message is expected" unless .is_a?(Mimi::Messaging::Message) response_serialized = dispatch_query(target, , opts) deserialize(response_serialized) end |
#start ⇒ Object
20 21 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 20 def start end |
#start_event_processor(topic_name, processor, _opts = {}) ⇒ Object
67 68 69 70 71 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 67 def start_event_processor(topic_name, processor, _opts = {}) super event_processors[topic_name] ||= [] event_processors[topic_name] << processor end |
#start_event_processor_with_queue(topic_name, queue_name, processor, opts = {}) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 73 def start_event_processor_with_queue(topic_name, queue_name, processor, opts = {}) super event_processors_with_queue[topic_name] ||= {} event_processors_with_queue[topic_name][queue_name] ||= [] event_processors_with_queue[topic_name][queue_name] << processor end |
#start_request_processor(queue_name, processor, _opts = {}) ⇒ Object
61 62 63 64 65 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 61 def start_request_processor(queue_name, processor, _opts = {}) super request_processors[queue_name] ||= [] request_processors[queue_name] << processor end |
#stop ⇒ Object
23 24 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 23 def stop end |
#stop_all_processors ⇒ Object
80 81 82 83 84 |
# File 'lib/mimi/messaging/adapters/memory.rb', line 80 def stop_all_processors @request_processors = {} @event_processors = {} @event_processors_with_queue = {} end |