Class: EventStoreClient::GRPC::Discover
- Inherits:
-
Object
- Object
- EventStoreClient::GRPC::Discover
- Defined in:
- lib/event_store_client/adapters/grpc/discover.rb
Class Method Summary collapse
- .current_member(config:) ⇒ EventStoreClient::GRPC::Cluster::Member
- .init_default_discover_vars ⇒ void
- .member_alive?(member) ⇒ Boolean
Instance Method Summary collapse
- #call(failed_member: nil) ⇒ EventStoreClient::GRPC::Cluster::Member
-
#initialize(config:) ⇒ Discover
constructor
A new instance of Discover.
Constructor Details
#initialize(config:) ⇒ Discover
Returns a new instance of Discover.
63 64 65 |
# File 'lib/event_store_client/adapters/grpc/discover.rb', line 63 def initialize(config:) @config = config end |
Class Method Details
.current_member(config:) ⇒ EventStoreClient::GRPC::Cluster::Member
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/event_store_client/adapters/grpc/discover.rb', line 11 def current_member(config:) @exception[config.name] = nil return @current_member[config.name] if member_alive?(@current_member[config.name]) semaphore(config.name).synchronize do current_member = @current_member[config.name] raise @exception[config.name] if @exception[config.name] return current_member if member_alive?(current_member) failed_member = current_member&.failed_endpoint ? current_member : nil begin @current_member[config.name] = new(config: config).call(failed_member: failed_member) rescue StandardError => e @exception[config.name] = e @current_member[config.name] = nil raise end end @current_member[config.name] end |
.init_default_discover_vars ⇒ void
This method returns an undefined value.
42 43 44 45 46 |
# File 'lib/event_store_client/adapters/grpc/discover.rb', line 42 def init_default_discover_vars @exception = {} @current_member = {} @semaphore = {} end |
.member_alive?(member) ⇒ Boolean
35 36 37 38 39 |
# File 'lib/event_store_client/adapters/grpc/discover.rb', line 35 def member_alive?(member) return false if member&.failed_endpoint !member.nil? end |
Instance Method Details
#call(failed_member: nil) ⇒ EventStoreClient::GRPC::Cluster::Member
69 70 71 72 73 74 75 76 77 |
# File 'lib/event_store_client/adapters/grpc/discover.rb', line 69 def call(failed_member: nil) if needs_discover? discovery = Cluster::GossipDiscover.new(config: config).call(nodes, failed_member: failed_member) return discovery end Cluster::QuerylessDiscover.new(config: config).call(config.eventstore_url.nodes.to_a) end |