Class: Lepus::ProcessRegistry::RabbitmqBackend
- Inherits:
-
Object
- Object
- Lepus::ProcessRegistry::RabbitmqBackend
- Includes:
- Backend
- Defined in:
- lib/lepus/process_registry/rabbitmq_backend.rb
Overview
RabbitMQ-based backend for process registry. Publishes heartbeats to a fanout exchange for web dashboard aggregation. Also writes locally via FileBackend for local queries when aggregator is unavailable.
Constant Summary collapse
- HEARTBEAT_EXCHANGE =
"lepus.heartbeat"
Instance Attribute Summary collapse
-
#fallback ⇒ Object
readonly
Returns the value of attribute fallback.
Instance Method Summary collapse
- #add(process, metrics: {}) ⇒ Object
- #all ⇒ Object
- #clear ⇒ Object
- #count ⇒ Object
- #delete(process) ⇒ Object
- #exists?(id) ⇒ Boolean
- #find(id) ⇒ Object
-
#initialize(fallback: nil) ⇒ RabbitmqBackend
constructor
A new instance of RabbitmqBackend.
- #path ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Backend
Constructor Details
#initialize(fallback: nil) ⇒ RabbitmqBackend
Returns a new instance of RabbitmqBackend.
18 19 20 21 22 23 24 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 18 def initialize(fallback: nil) @fallback = fallback || FileBackend.new @connection = nil @channel = nil @exchange = nil @mutex = Mutex.new end |
Instance Attribute Details
#fallback ⇒ Object (readonly)
Returns the value of attribute fallback.
16 17 18 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 16 def fallback @fallback end |
Instance Method Details
#add(process, metrics: {}) ⇒ Object
36 37 38 39 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 36 def add(process, metrics: {}) @fallback.add(process) publish_heartbeat(process, metrics: metrics) end |
#all ⇒ Object
54 55 56 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 54 def all @fallback.all end |
#clear ⇒ Object
62 63 64 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 62 def clear @fallback.clear end |
#count ⇒ Object
58 59 60 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 58 def count @fallback.count end |
#delete(process) ⇒ Object
41 42 43 44 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 41 def delete(process) @fallback.delete(process) publish_deregister(process) end |
#exists?(id) ⇒ Boolean
50 51 52 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 50 def exists?(id) @fallback.exists?(id) end |
#find(id) ⇒ Object
46 47 48 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 46 def find(id) @fallback.find(id) end |
#path ⇒ Object
66 67 68 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 66 def path @fallback.path end |
#start ⇒ Object
26 27 28 29 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 26 def start @fallback.start setup_channel_and_exchange end |
#stop ⇒ Object
31 32 33 34 |
# File 'lib/lepus/process_registry/rabbitmq_backend.rb', line 31 def stop @fallback.stop close_channel end |