Sha256: 88443e3270e97ae35dd626a722ce1c4afca05d15c2efc3f9450aa572cf06496c

Contents?: true

Size: 823 Bytes

Versions: 5

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

require 'redis/errors'

class Redis
  class Cluster
    # Load details about Redis commands for Redis Cluster Client
    # @see https://redis.io/commands/command
    module CommandLoader
      module_function

      def load(nodes)
        errors = nodes.map do |node|
          begin
            return fetch_command_details(node)
          rescue CannotConnectError, ConnectionError, CommandError => error
            error
          end
        end

        raise InitialSetupError, errors
      end

      def fetch_command_details(node)
        node.call(%i[command]).map do |reply|
          [reply[0], { arity: reply[1], flags: reply[2], first: reply[3], last: reply[4], step: reply[5] }]
        end.to_h
      end

      private_class_method :fetch_command_details
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/redis-4.8.1/lib/redis/cluster/command_loader.rb
redis-4.8.1 lib/redis/cluster/command_loader.rb
redis-4.8.0 lib/redis/cluster/command_loader.rb
redis-4.7.1 lib/redis/cluster/command_loader.rb
redis-4.7.0 lib/redis/cluster/command_loader.rb