Class: Reacter::RelayAgent
Instance Attribute Summary
Attributes inherited from Agent
Instance Method Summary collapse
-
#initialize ⇒ RelayAgent
constructor
A new instance of RelayAgent.
- #received(message) ⇒ Object
Methods inherited from Agent
Constructor Details
#initialize ⇒ RelayAgent
Returns a new instance of RelayAgent.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/reacter/agents/relay.rb', line 9 def initialize() super @_adapters = [] @_signature = Util.signature(object_id.to_s(16).upcase) @config = (@config.is_a?(Hash) ? [@config] : [*@config]) @config.each do |c| if c['type'] adapter = Adapter.create(c['type'], c) adapter.connect({ :mode => 'write' }) @_adapters << adapter Util.info("Relaying messages via #{c['type']} adapter") end end @_adapter_cycle = @_adapters.cycle.each end |
Instance Method Details
#received(message) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/reacter/agents/relay.rb', line 31 def received() adapter = @_adapter_cycle.next if adapter [:relayed_from] = @_signature unless (adapter.config['transparent'] === true) adapter.send(, adapter.config['format']) else Util.warn("relay: Message received without an active relay adapter, dropping") return false end return end |