Class: Kestrel::Client::Partitioning

Inherits:
Proxy
  • Object
show all
Defined in:
lib/kestrel/client/partitioning.rb

Instance Method Summary collapse

Methods inherited from Proxy

#method_missing

Constructor Details

#initialize(client_map) ⇒ Partitioning

Returns a new instance of Partitioning.



5
6
7
8
9
10
11
# File 'lib/kestrel/client/partitioning.rb', line 5

def initialize(client_map)
  @clients = client_map.inject({}) do |clients, (keys, client)|
    Array(keys).inject(clients) do |_, key|
      clients.update(key => client)
    end
  end
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Kestrel::Client::Proxy

Instance Method Details

#client_for(key) ⇒ Object



30
31
32
# File 'lib/kestrel/client/partitioning.rb', line 30

def client_for(key)
  @clients[key.to_s.split('/', 2).first] || default_client
end

#clientsObject



13
14
15
# File 'lib/kestrel/client/partitioning.rb', line 13

def clients
  @clients.values.uniq
end

#default_clientObject Also known as: client



17
18
19
# File 'lib/kestrel/client/partitioning.rb', line 17

def default_client
  @clients[:default]
end

#statsObject



26
27
28
# File 'lib/kestrel/client/partitioning.rb', line 26

def stats
  merge_stats(clients.map {|c| c.stats })
end