Sha256: 722d0d8c58f0e6d11d1e5f9c48a60be3bf8c38d49e4090352970fa82dcef35dc
Contents?: true
Size: 879 Bytes
Versions: 2
Compression:
Stored size: 879 Bytes
Contents
# frozen_string_literal: true require_relative '../errors' class Redis class Cluster # Load and hashify node info for Redis Cluster Client module NodeLoader module_function 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 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 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
redis-4.0.3 | lib/redis/cluster/node_loader.rb |
redis-4.1.0.beta1 | lib/redis/cluster/node_loader.rb |