Class: Pebblebed::QuorumClient

Inherits:
AbstractClient show all
Defined in:
lib/pebblebed/clients/quorum_client.rb

Instance Method Summary collapse

Methods inherited from AbstractClient

#delete, #get, #post, #put

Constructor Details

#initialize(services, session_key) ⇒ QuorumClient

Returns a new instance of QuorumClient.



7
8
9
10
11
12
# File 'lib/pebblebed/clients/quorum_client.rb', line 7

def initialize(services, session_key)
  #::LOGGER.warn "DEPRECATED: The Pebblebed::QuorumClient is no longer supported."
  @clients = Hash[services.map do |service|
    [service, Pebblebed::GenericClient.new(session_key, Pebblebed.root_url_for(service))]
  end]
end

Instance Method Details

#perform(method, url = '', params = {}, &block) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/pebblebed/clients/quorum_client.rb', line 14

def perform(method, url = '', params = {}, &block)
  # Using Future::Value perform the full quorum in parallel
  results = @clients.map do |service, client|
    response = [service]
    response << Future::Value.new do 
      begin
        client.perform(method, url, params, &block) 
      rescue HttpError => e
        e
      end
    end
    response
  end
  # Unwrap future values and thereby joining all threads
  Hash[results.map{|service, response| [service, response.value]}]
end