Module: Cellect::Client
- Defined in:
- lib/cellect/client.rb,
lib/cellect/client/node_set.rb,
lib/cellect/client/connection.rb
Defined Under Namespace
Classes: CellectServerError, Connection, NodeSet
Class Method Summary collapse
-
.choose_host ⇒ Object
Selects a server for a user.
- .connection ⇒ Object
-
.host_exists?(ip) ⇒ Boolean
Ensure a previously selected server is still available.
-
.node_set ⇒ Object
Sets up the set of server nodes.
Class Method Details
.choose_host ⇒ Object
Selects a server for a user
19 20 21 22 |
# File 'lib/cellect/client.rb', line 19 def self.choose_host host = node_set.nodes.sample host && host['ip'] end |
.connection ⇒ Object
14 15 16 |
# File 'lib/cellect/client.rb', line 14 def self.connection @connection ||= Connection.new end |
.host_exists?(ip) ⇒ Boolean
Ensure a previously selected server is still available
25 26 27 |
# File 'lib/cellect/client.rb', line 25 def self.host_exists?(ip) node_set.nodes.select{ |node| node['ip'] == ip }.length > 0 end |