Class: EventStore::Cluster::LeaderStatus::GossipEndpoint::Get
- Inherits:
-
Object
- Object
- EventStore::Cluster::LeaderStatus::GossipEndpoint::Get
- Includes:
- Log::Dependency
- Defined in:
- lib/event_store/cluster/leader_status/gossip_endpoint/get.rb
Defined Under Namespace
Modules: LogAttributes
Constant Summary collapse
- NonClusterError =
Class.new StandardError
Class Method Summary collapse
Instance Method Summary collapse
- #call(host = nil) ⇒ Object
- #http_headers ⇒ Object
- #non_cluster?(response) ⇒ Boolean
- #uri_path ⇒ Object
Class Method Details
.build(connect_http = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/event_store/cluster/leader_status/gossip_endpoint/get.rb', line 12 def self.build(connect_http=nil) instance = new connect_http = EventStore::HTTP::Connect.configure( instance, connect: connect_http, attr_name: :connect_http ) instance end |
.call(host = nil, connect_http = nil) ⇒ Object
24 25 26 27 |
# File 'lib/event_store/cluster/leader_status/gossip_endpoint/get.rb', line 24 def self.call(host=nil, connect_http=nil) instance = build connect_http instance.(host) end |
Instance Method Details
#call(host = nil) ⇒ Object
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 56 57 58 59 60 |
# File 'lib/event_store/cluster/leader_status/gossip_endpoint/get.rb', line 29 def call(host=nil) log_attributes = LogAttributes.get self, host: host logger.trace { "GET gossip endpoint (#{log_attributes})" } connection_telemetry = EventStore::HTTP::Connect.register_telemetry_sink connect_http connect_http.(host) do |connection| begin response = connection.request_get uri_path, http_headers rescue Net::ReadTimeout response = nil end if response log_attributes << ", StatusCode: #{response.code}, ReasonPhrase: #{response.message}" logger.debug { "GET gossip endpoint done (#{log_attributes})" } logger.trace { "Data: \n\n#{response.body}" } end if response.nil? or non_cluster? response = "GET gossip endpoint made against non-clustered EventStore (#{log_attributes})" logger.error raise NonClusterError, end response = Transform::Read.(response.body, :json, Response) return response end end |
#http_headers ⇒ Object
66 67 68 |
# File 'lib/event_store/cluster/leader_status/gossip_endpoint/get.rb', line 66 def http_headers { 'Accept' => 'application/json' } end |
#non_cluster?(response) ⇒ Boolean
70 71 72 |
# File 'lib/event_store/cluster/leader_status/gossip_endpoint/get.rb', line 70 def non_cluster?(response) response.code == '408' and response. == "Server was unable to handle request in time" end |
#uri_path ⇒ Object
62 63 64 |
# File 'lib/event_store/cluster/leader_status/gossip_endpoint/get.rb', line 62 def uri_path '/gossip' end |