Module: EventStore::HTTP::Controls::Hostname::Resolution::HostsFile

Defined in:
lib/event_store/http/controls/hostname/resolution.rb

Class Method Summary collapse

Class Method Details

.getObject



17
18
19
20
21
22
23
24
25
# File 'lib/event_store/http/controls/hostname/resolution.rb', line 17

def self.get
  tempfile = Tempfile.new 'hosts'
  tempfile.write text
  tempfile.close

  at_exit { tempfile.unlink }

  tempfile.path
end

.textObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/event_store/http/controls/hostname/resolution.rb', line 27

def self.text
  leader_ip_address, *follower_ip_addresses = Controls::Cluster::CurrentMembers.get

  ERB.new(<<~ERB, 0, '>').result binding
  <%= IPAddress::Available.example %> <%= Hostname::Available.example %>\n
  <%= IPAddress::Available.example %> <%= Hostname::Available::Other.example %>\n
  <%= IPAddress::Unavailable.example %> <%= Hostname::Unavailable.example %>\n

  <% (1..Controls::Cluster::Size.example).each do |member_index| %>
  <%= IPAddress::Cluster::Available.example member_index %> <%= Hostname::Cluster::Available.example %>\n
  <%= IPAddress::Cluster::Available.example member_index %> <%= Hostname::Cluster::Available::Member.example member_index %>\n
  <% end %>

  <% (1..Controls::Cluster::Size.example).each do |member_index| %>
  <%= IPAddress::Cluster::Unavailable.example member_index %> <%= Hostname::Cluster::Unavailable.example %>\n
  <%= IPAddress::Cluster::Unavailable.example member_index %> <%= Hostname::Cluster::Unavailable::Member.example member_index %>\n
  <% end %>

  <% (1..Controls::Cluster::Size.example).each do |member_index| %>
  <%= IPAddress::Cluster::PartiallyAvailable.example member_index %> <%= Hostname::Cluster::PartiallyAvailable.example %>\n
  <%= IPAddress::Cluster::PartiallyAvailable.example member_index %> <%= Hostname::Cluster::PartiallyAvailable::Member.example member_index %>\n
  <% end %>

  <%= leader_ip_address %> <%= Hostname::Cluster::Leader.example %>\n
  <% follower_ip_addresses.each do |follower_ip_address| %>
  <%= follower_ip_address %> <%= Hostname::Cluster::Followers.example %>\n
  <% end %>
  ERB
end