Class: RedisClient::Cluster::Node::PrimaryOnly

Inherits:
BaseTopology
  • Object
show all
Defined in:
lib/redis_client/cluster/node/primary_only.rb

Constant Summary

Constants inherited from BaseTopology

BaseTopology::IGNORE_GENERIC_CONFIG_KEYS

Instance Attribute Summary

Attributes inherited from BaseTopology

#clients

Instance Method Summary collapse

Methods inherited from BaseTopology

#initialize

Constructor Details

This class inherits a constructor from RedisClient::Cluster::Node::BaseTopology

Instance Method Details

#any_primary_node_key(seed: nil) ⇒ Object Also known as: any_replica_node_key



20
21
22
23
# File 'lib/redis_client/cluster/node/primary_only.rb', line 20

def any_primary_node_key(seed: nil)
  random = seed.nil? ? Random : Random.new(seed)
  @primary_node_keys.sample(random: random)
end

#clients_for_scanning(seed: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



12
13
14
# File 'lib/redis_client/cluster/node/primary_only.rb', line 12

def clients_for_scanning(seed: nil) # rubocop:disable Lint/UnusedMethodArgument
  @clients
end

#find_node_key_of_replica(primary_node_key, seed: nil) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument



16
17
18
# File 'lib/redis_client/cluster/node/primary_only.rb', line 16

def find_node_key_of_replica(primary_node_key, seed: nil) # rubocop:disable Lint/UnusedMethodArgument
  primary_node_key
end

#process_topology_update!(replications, options) ⇒ Object



27
28
29
30
31
# File 'lib/redis_client/cluster/node/primary_only.rb', line 27

def process_topology_update!(replications, options)
  # Remove non-primary nodes from options (provided that we actually have any primaries at all)
  options = options.select { |node_key, _| replications.key?(node_key) } if replications.keys.any?
  super(replications, options)
end