Class: RedisClient::Cluster::Node::PrimaryOnly
- Inherits:
-
Object
- Object
- RedisClient::Cluster::Node::PrimaryOnly
- Defined in:
- lib/redis_client/cluster/node/primary_only.rb
Instance Attribute Summary collapse
-
#clients ⇒ Object
(also: #primary_clients, #replica_clients)
readonly
Returns the value of attribute clients.
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.
-
#initialize(replications, options, pool, _concurrent_worker, **kwargs) ⇒ PrimaryOnly
constructor
A new instance of PrimaryOnly.
Constructor Details
#initialize(replications, options, pool, _concurrent_worker, **kwargs) ⇒ PrimaryOnly
Returns a new instance of PrimaryOnly.
9 10 11 12 |
# File 'lib/redis_client/cluster/node/primary_only.rb', line 9 def initialize(replications, , pool, _concurrent_worker, **kwargs) @primary_node_keys = replications.keys.sort @clients = build_clients(@primary_node_keys, , pool, **kwargs) end |
Instance Attribute Details
#clients ⇒ Object (readonly) Also known as: primary_clients, replica_clients
Returns the value of attribute clients.
7 8 9 |
# File 'lib/redis_client/cluster/node/primary_only.rb', line 7 def clients @clients end |
Instance Method Details
#any_primary_node_key(seed: nil) ⇒ Object Also known as: any_replica_node_key
25 26 27 28 |
# File 'lib/redis_client/cluster/node/primary_only.rb', line 25 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
17 18 19 |
# File 'lib/redis_client/cluster/node/primary_only.rb', line 17 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
21 22 23 |
# File 'lib/redis_client/cluster/node/primary_only.rb', line 21 def find_node_key_of_replica(primary_node_key, seed: nil) # rubocop:disable Lint/UnusedMethodArgument primary_node_key end |