Module: RSMP::SiteProxy::Modules::AggregatedStatus
- Included in:
- RSMP::SiteProxy
- Defined in:
- lib/rsmp/proxy/site/modules/aggregated_status.rb
Overview
Handles aggregated status requests and responses
Instance Method Summary collapse
- #aggregated_status_changed(component, _options = {}) ⇒ Object
- #process_aggregated_status(message) ⇒ Object
-
#request_aggregated_status(component, m_id: nil, validate: true) ⇒ Object
Build and send an AggregatedStatusRequest.
-
#request_aggregated_status_and_collect(component, within:, m_id: nil, validate: true) ⇒ Object
Build, send an AggregatedStatusRequest and collect the response.
- #validate_aggregated_status(message, status_elements) ⇒ Object
Instance Method Details
#aggregated_status_changed(component, _options = {}) ⇒ Object
57 58 59 |
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 57 def aggregated_status_changed(component, = {}) @supervisor.aggregated_status_changed self, component end |
#process_aggregated_status(message) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 40 def process_aggregated_status() status_elements = .attribute('se') validate_aggregated_status(, status_elements) c_id = .attributes['cId'] component = find_component c_id unless component reason = "component #{c_id} not found" dont_acknowledge , "Ignoring #{.type}:", reason return end component.aggregated_status_bools = status_elements log "Received #{.type} status for component #{c_id} [#{component.aggregated_status.join(', ')}]", message: acknowledge end |
#request_aggregated_status(component, m_id: nil, validate: true) ⇒ Object
Build and send an AggregatedStatusRequest. Returns { sent: message }.
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 7 def request_aggregated_status(component, m_id: nil, validate: true) validate_ready 'request aggregated status' m_id ||= RSMP::Message.make_m_id = RSMP::AggregatedStatusRequest.new({ 'cId' => component, 'mId' => m_id }) , validate: validate { sent: } end |
#request_aggregated_status_and_collect(component, within:, m_id: nil, validate: true) ⇒ Object
Build, send an AggregatedStatusRequest and collect the response. Returns the collector. Call .ok! on the result to raise on NotAck or timeout.
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 21 def request_aggregated_status_and_collect(component, within:, m_id: nil, validate: true) validate_ready 'request aggregated status' m_id ||= RSMP::Message.make_m_id = RSMP::AggregatedStatusRequest.new({ 'cId' => component, 'mId' => m_id }) collector = AggregatedStatusCollector.new(self, timeout: within, m_id: m_id, num: 1) (, collector, validate: validate)[:collector] end |
#validate_aggregated_status(message, status_elements) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/rsmp/proxy/site/modules/aggregated_status.rb', line 33 def validate_aggregated_status(, status_elements) return if status_elements.is_a?(Array) && status_elements.size == 8 dont_acknowledge , 'Received', reaons raise InvalidMessage end |