module Redis::Cluster::NodeLoader
def fetch_node_info(node)
def fetch_node_info(node) node.call(%i[cluster nodes]) .split("\n") .map { |str| str.split(' ') } .map { |arr| [arr[1].split('@').first, (arr[2].split(',') & %w[master slave]).first] } .to_h rescue CannotConnectError, ConnectionError, CommandError {} # can retry on another node end
def load_flags(nodes)
def load_flags(nodes) info = {} nodes.each do |node| info = fetch_node_info(node) info.empty? ? next : break end return info unless info.empty? raise CannotConnectError, 'Redis client could not connect to any cluster nodes' end