Class: EventStore::Cluster::LeaderStatus::Get

Inherits:
Object
  • Object
show all
Includes:
Log::Dependency
Defined in:
lib/event_store/cluster/leader_status/get.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build(connect_http = nil) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/event_store/cluster/leader_status/get.rb', line 11

def self.build(connect_http=nil)
  instance = new

  GossipEndpoint::Get.configure instance, connect_http

  instance
end

.call(*arguments) ⇒ Object



19
20
21
22
# File 'lib/event_store/cluster/leader_status/get.rb', line 19

def self.call(*arguments)
  instance = build *arguments
  instance.()
end

Instance Method Details

#callObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/event_store/cluster/leader_status/get.rb', line 24

def call
  logger.trace { "Getting leader" }

  gossip_response = get_gossip_endpoint.()

  if gossip_response.nil?
    logger.info { "Get leader done; EventStore is non-clustered" }
    return nil
  end

  data = Data.new

  SetAttributes.(
    data,
    gossip_response.leader,
    copy: [
      { :external_tcp_ip => :tcp_ip_address },
      { :external_tcp_port => :tcp_port },
      { :external_http_ip => :http_ip_address },
      { :external_http_port => :http_port }
    ]
  )

  logger.info { "Get leader done (TCP: #{data.tcp_ip_address}:#{data.tcp_port}, HTTP: #{data.http_ip_address}:#{data.http_port})" }

  data
end