Class: RedisClient::Cluster::Node::PrimaryOnly
- Inherits:
-
BaseTopology
- Object
- BaseTopology
- RedisClient::Cluster::Node::PrimaryOnly
- 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
Instance Method Summary collapse
- #any_primary_node_key(seed: nil) ⇒ Object (also: #any_replica_node_key)
-
#clients_for_scanning(seed: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
-
#find_node_key_of_replica(primary_node_key, seed: nil) ⇒ Object
rubocop:disable Lint/UnusedMethodArgument.
- #process_topology_update!(replications, options) ⇒ Object
Methods inherited from BaseTopology
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, ) # Remove non-primary nodes from options (provided that we actually have any primaries at all) = .select { |node_key, _| replications.key?(node_key) } if replications.keys.any? super(replications, ) end |