Module: RedisClient::Cluster::Node::ReplicaMixin
- Included in:
- LatencyReplica, RandomReplica, RandomReplicaOrPrimary
- Defined in:
- lib/redis_client/cluster/node/replica_mixin.rb
Constant Summary collapse
- EMPTY_ARRAY =
[].freeze
Instance Attribute Summary collapse
-
#clients ⇒ Object
readonly
Returns the value of attribute clients.
-
#primary_clients ⇒ Object
readonly
Returns the value of attribute primary_clients.
Instance Method Summary collapse
- #any_primary_node_key(seed: nil) ⇒ Object
- #initialize(replications, options, pool, _concurrent_worker, **kwargs) ⇒ Object
Instance Attribute Details
#clients ⇒ Object (readonly)
Returns the value of attribute clients.
7 8 9 |
# File 'lib/redis_client/cluster/node/replica_mixin.rb', line 7 def clients @clients end |
#primary_clients ⇒ Object (readonly)
Returns the value of attribute primary_clients.
7 8 9 |
# File 'lib/redis_client/cluster/node/replica_mixin.rb', line 7 def primary_clients @primary_clients end |
Instance Method Details
#any_primary_node_key(seed: nil) ⇒ Object
19 20 21 22 |
# File 'lib/redis_client/cluster/node/replica_mixin.rb', line 19 def any_primary_node_key(seed: nil) random = seed.nil? ? Random : Random.new(seed) @primary_node_keys.sample(random: random) end |
#initialize(replications, options, pool, _concurrent_worker, **kwargs) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/redis_client/cluster/node/replica_mixin.rb', line 11 def initialize(replications, , pool, _concurrent_worker, **kwargs) @replications = replications @primary_node_keys = @replications.keys.sort @replica_node_keys = @replications.values.flatten.sort @clients = build_clients(@primary_node_keys, , pool, **kwargs) @primary_clients = @clients.select { |k, _| @primary_node_keys.include?(k) } end |