class AnyCable::Config

def to_redis_params

Build Redis parameters
def to_redis_params
  # @type var base_params: { url: String, sentinels: Array[untyped]?, ssl_params: Hash[Symbol, untyped]? }
  base_params = {url: redis_url}
  base_params.tap do |params|
    sentinels = redis_sentinels
    next if sentinels.nil? || sentinels.empty?
    sentinels = Array(sentinels) unless sentinels.is_a?(Array)
    next if sentinels.empty?
    params[:sentinels] = sentinels.map { |sentinel| parse_sentinel(sentinel) }
  end.tap do |params|
    next unless redis_url.match?(/rediss:\/\//)
    if !!redis_tls_client_cert_path ^ !!redis_tls_client_key_path
      raise_validation_error "Both Redis TLS client certificate and private key must be specified (or none of them)"
    end
    if !redis_tls_verify?
      params[:ssl_params] = {verify_mode: OpenSSL::SSL::VERIFY_NONE}
    else
      cert_path, key_path = redis_tls_client_cert_path, redis_tls_client_key_path
      if cert_path && key_path
        params[:ssl_params] = {
          cert: OpenSSL::X509::Certificate.new(File.read(cert_path)),
          key: OpenSSL::PKey.read(File.read(key_path))
        }
      end
    end
  end
end