Module: RedisClient::Cluster::NodeKey
- Defined in:
- lib/redis_client/cluster/node_key.rb
Overview
Node key’s format is ‘<ip>:<port>`. It is different from node id. Node id is internal identifying code in Redis Cluster.
Class Method Summary collapse
- .build_from_client(client) ⇒ Object
- .build_from_host_port(host, port) ⇒ Object
- .build_from_uri(uri) ⇒ Object
- .hashify(node_key) ⇒ Object
- .split(node_key) ⇒ Object
Class Method Details
.build_from_client(client) ⇒ Object
37 38 39 |
# File 'lib/redis_client/cluster/node_key.rb', line 37 def build_from_client(client) "#{client.config.host}#{DELIMITER}#{client.config.port}" end |
.build_from_host_port(host, port) ⇒ Object
33 34 35 |
# File 'lib/redis_client/cluster/node_key.rb', line 33 def build_from_host_port(host, port) "#{host}#{DELIMITER}#{port}" end |
.build_from_uri(uri) ⇒ Object
27 28 29 30 31 |
# File 'lib/redis_client/cluster/node_key.rb', line 27 def build_from_uri(uri) return '' if uri.nil? "#{uri.host}#{DELIMITER}#{uri.port}" end |
.hashify(node_key) ⇒ Object
15 16 17 18 |
# File 'lib/redis_client/cluster/node_key.rb', line 15 def hashify(node_key) host, port = split(node_key) { host: host, port: port } end |
.split(node_key) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/redis_client/cluster/node_key.rb', line 20 def split(node_key) pos = node_key&.rindex(DELIMITER, -1) return [node_key, nil] if pos.nil? [node_key[0, pos], node_key[(pos + 1)..]] end |