Sha256: 1b52693683a99b4d4e9f353498dcdb7f6cdf847e68bb64ee65f4699ec8063ccd

Contents?: true

Size: 838 Bytes

Versions: 14

Compression:

Stored size: 838 Bytes

Contents

# frozen_string_literal: true

require_relative '../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)
        details = {}

        nodes.each do |node|
          details = fetch_command_details(node)
          details.empty? ? next : break
        end

        details
      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
      rescue CannotConnectError, ConnectionError, CommandError
        {} # can retry on another node
      end

      private_class_method :fetch_command_details
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
redis-4.4.0 lib/redis/cluster/command_loader.rb
redis-4.3.1 lib/redis/cluster/command_loader.rb
redis-4.3.0 lib/redis/cluster/command_loader.rb
redis-4.2.5 lib/redis/cluster/command_loader.rb
redis-4.2.4 lib/redis/cluster/command_loader.rb
redis-4.2.3 lib/redis/cluster/command_loader.rb
redis-4.2.2 lib/redis/cluster/command_loader.rb
redis-4.2.1 lib/redis/cluster/command_loader.rb
redis-4.2.0 lib/redis/cluster/command_loader.rb
redis-4.1.4 lib/redis/cluster/command_loader.rb
redis-4.1.3 lib/redis/cluster/command_loader.rb
redis-4.1.2 lib/redis/cluster/command_loader.rb
redis-4.1.1 lib/redis/cluster/command_loader.rb
redis-4.1.0 lib/redis/cluster/command_loader.rb