Sha256: 2ee5a8a741ff11bb0a858c2a7f8a815257ad619d6af2346c78470b7c9553ba45
Contents?: true
Size: 806 Bytes
Versions: 5
Compression:
Stored size: 806 Bytes
Contents
# frozen_string_literal: true require 'redis/errors' class Redis class Cluster # Load and hashify node info for Redis Cluster Client module NodeLoader module_function def load_flags(nodes) errors = nodes.map do |node| begin return fetch_node_info(node) rescue CannotConnectError, ConnectionError, CommandError => error error end end raise InitialSetupError, errors 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 end private_class_method :fetch_node_info end end end
Version data entries
5 entries across 5 versions & 2 rubygems