class RedisClient::SentinelConfig
def initialize(name:, sentinels:, role: :master, **client_config)
def initialize(name:, sentinels:, role: :master, **client_config) unless %i(master replica slave).include?(role) raise ArgumentError, "Expected role to be either :master or :replica, got: #{role.inspect}" end @to_list_of_hash = @to_hash = nil @extra_config = {} if client_config[:protocol] == 2 @extra_config[:protocol] = client_config[:protocol] @to_list_of_hash = lambda do |may_be_a_list| if may_be_a_list.is_a?(Array) may_be_a_list.map { |l| l.each_slice(2).to_h } else may_be_a_list end end end @name = name @sentinel_configs = sentinels_to_configs(sentinels) @sentinels = {}.compare_by_identity @role = role @mutex = Mutex.new @config = nil client_config[:reconnect_attempts] ||= DEFAULT_RECONNECT_ATTEMPTS @client_config = client_config || {} super(**client_config) end