module Redis::Cluster::NodeKey

Node key's format is `<ip>:<port>`. It is different from node id. Node id is internal identifying code in Redis Cluster.

Constants

DEFAULT_SCHEME
DELIMITER
SECURE_SCHEME

Public Instance Methods

build_from_host_port(host, port) click to toggle source
# File lib/redis/cluster/node_key.rb, line 29
def build_from_host_port(host, port)
  "#{host}#{DELIMITER}#{port}"
end
build_from_uri(uri) click to toggle source
# File lib/redis/cluster/node_key.rb, line 25
def build_from_uri(uri)
  "#{uri.host}#{DELIMITER}#{uri.port}"
end
split(node_key) click to toggle source
# File lib/redis/cluster/node_key.rb, line 21
def split(node_key)
  node_key.split(DELIMITER)
end
to_node_urls(node_keys, secure:) click to toggle source
# File lib/redis/cluster/node_key.rb, line 14
def to_node_urls(node_keys, secure:)
  scheme = secure ? SECURE_SCHEME : DEFAULT_SCHEME
  node_keys
    .map { |k| k.split(DELIMITER) }
    .map { |k| URI::Generic.build(scheme: scheme, host: k[0], port: k[1].to_i).to_s }
end