Module: RSMP::Supervisor::Modules::Sites

Included in:
RSMP::Supervisor
Defined in:
lib/rsmp/node/supervisor/modules/sites.rb

Overview

Manages connected sites and site discovery

Instance Method Summary collapse

Instance Method Details

#aggregated_status_changed(site_proxy, component) ⇒ Object



60
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 60

def aggregated_status_changed(site_proxy, component); end

#check_site_already_connected(site_id) ⇒ Object

Raises:



51
52
53
54
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 51

def check_site_already_connected(site_id)
  site = find_site(site_id)
  raise HandshakeError, "Site '#{site_id}' already connected" if !site.nil? && site != self
end

#check_site_id(site_id) ⇒ Object



46
47
48
49
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 46

def check_site_id(site_id)
  # check_site_already_connected site_id
  site_id_to_site_setting site_id
end

#find_site(site_id) ⇒ Object



17
18
19
20
21
22
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 17

def find_site(site_id)
  @proxies.each do |site|
    return site if site_id == :any || site.site_id == site_id
  end
  nil
end

#find_site_from_ip_port(ip, port) ⇒ Object



10
11
12
13
14
15
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 10

def find_site_from_ip_port(ip, port)
  @proxies.each do |site|
    return site if site.ip == ip && site.port == port
  end
  nil
end

#site_connected?(site_id) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 6

def site_connected?(site_id)
  !find_site(site_id).nil?
end

#site_ids_changedObject



56
57
58
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 56

def site_ids_changed
  @site_id_condition.signal
end

#wait_for_site(site_id, timeout:) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 24

def wait_for_site(site_id, timeout:)
  site = find_site site_id
  return site if site

  wait_for_condition(@site_id_condition, timeout: timeout) do
    find_site site_id
  end
rescue Async::TimeoutError
  str = if site_id == :any
          'No site connected'
        else
          "Site '#{site_id}' did not connect"
        end
  raise RSMP::TimeoutError, "#{str} within #{timeout}s"
end

#wait_for_site_disconnect(site_id, timeout:) ⇒ Object



40
41
42
43
44
# File 'lib/rsmp/node/supervisor/modules/sites.rb', line 40

def wait_for_site_disconnect(site_id, timeout:)
  wait_for_condition(@site_id_condition, timeout: timeout) { true unless find_site site_id }
rescue Async::TimeoutError
  raise RSMP::TimeoutError, "Site '#{site_id}' did not disconnect within #{timeout}s"
end