Class: EventStoreClient::GRPC::Cluster::GossipDiscover
- Inherits:
-
Object
- Object
- EventStoreClient::GRPC::Cluster::GossipDiscover
- Defined in:
- lib/event_store_client/adapters/grpc/cluster/gossip_discover.rb
Constant Summary collapse
- DiscoverError =
Class.new(StandardError)
- READ_ONLY_STATES =
Order is important - it plays role of states priority as well
%i[ReadOnlyReplica PreReadOnlyReplica ReadOnlyLeaderless].freeze
- ALLOWED_NODE_STATES =
(%i[Leader Follower] + READ_ONLY_STATES).freeze
Instance Method Summary collapse
- #call(nodes, failed_member:) ⇒ EventStoreClient::GRPC::Cluster::Member
-
#initialize(config:) ⇒ GossipDiscover
constructor
A new instance of GossipDiscover.
Constructor Details
#initialize(config:) ⇒ GossipDiscover
Returns a new instance of GossipDiscover.
20 21 22 |
# File 'lib/event_store_client/adapters/grpc/cluster/gossip_discover.rb', line 20 def initialize(config:) @config = config end |
Instance Method Details
#call(nodes, failed_member:) ⇒ EventStoreClient::GRPC::Cluster::Member
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/event_store_client/adapters/grpc/cluster/gossip_discover.rb', line 28 def call(nodes, failed_member:) nodes = sort_nodes(nodes, failed_member) attempts = config.eventstore_url.max_discover_attempts attempts.times do nodes.each do |node| suitable_member = suitable_member_of_node(node) next unless suitable_member return suitable_member end sleep(config.eventstore_url.discover_interval / 1000.0) end raise DiscoverError, "Failed to discover suitable host after #{attempts} attempts." end |