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

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

Class Method Summary collapse

Class Method Details

.get ⇒ Object



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

.text ⇒ Object



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("  <%= IPAddress::Available.example %> <%= Hostname::Available.example %>\\n\n  <%= IPAddress::Available.example %> <%= Hostname::Available::Other.example %>\\n\n  <%= IPAddress::Unavailable.example %> <%= Hostname::Unavailable.example %>\\n\n\n  <% (1..Controls::Cluster::Size.example).each do |member_index| %>\n  <%= IPAddress::Cluster::Available.example member_index %> <%= Hostname::Cluster::Available.example %>\\n\n  <%= IPAddress::Cluster::Available.example member_index %> <%= Hostname::Cluster::Available::Member.example member_index %>\\n\n  <% end %>\n\n  <% (1..Controls::Cluster::Size.example).each do |member_index| %>\n  <%= IPAddress::Cluster::Unavailable.example member_index %> <%= Hostname::Cluster::Unavailable.example %>\\n\n  <%= IPAddress::Cluster::Unavailable.example member_index %> <%= Hostname::Cluster::Unavailable::Member.example member_index %>\\n\n  <% end %>\n\n  <% (1..Controls::Cluster::Size.example).each do |member_index| %>\n  <%= IPAddress::Cluster::PartiallyAvailable.example member_index %> <%= Hostname::Cluster::PartiallyAvailable.example %>\\n\n  <%= IPAddress::Cluster::PartiallyAvailable.example member_index %> <%= Hostname::Cluster::PartiallyAvailable::Member.example member_index %>\\n\n  <% end %>\n\n  <%= leader_ip_address %> <%= Hostname::Cluster::Leader.example %>\\n\n  <% follower_ip_addresses.each do |follower_ip_address| %>\n  <%= follower_ip_address %> <%= Hostname::Cluster::Followers.example %>\\n\n  <% end %>\n  ERB\nend\n", 0, '>').result binding