redis-cluster-client 0.7.5 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/redis_client/cluster/command.rb +53 -17
- data/lib/redis_client/cluster/error_identification.rb +55 -0
- data/lib/redis_client/cluster/key_slot_converter.rb +18 -0
- data/lib/redis_client/cluster/node/base_topology.rb +60 -0
- data/lib/redis_client/cluster/node/latency_replica.rb +13 -17
- data/lib/redis_client/cluster/node/primary_only.rb +7 -19
- data/lib/redis_client/cluster/node/random_replica.rb +2 -4
- data/lib/redis_client/cluster/node/random_replica_or_primary.rb +2 -4
- data/lib/redis_client/cluster/node.rb +160 -107
- data/lib/redis_client/cluster/node_key.rb +4 -0
- data/lib/redis_client/cluster/optimistic_locking.rb +72 -0
- data/lib/redis_client/cluster/pinning_node.rb +35 -0
- data/lib/redis_client/cluster/pipeline.rb +22 -14
- data/lib/redis_client/cluster/router.rb +75 -80
- data/lib/redis_client/cluster/transaction.rb +140 -20
- data/lib/redis_client/cluster.rb +47 -4
- data/lib/redis_client/cluster_config.rb +30 -45
- metadata +9 -6
- data/lib/redis_client/cluster/node/replica_mixin.rb +0 -37
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis-cluster-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Taishi Kasuga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.22'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.22'
|
27
27
|
description:
|
28
28
|
email:
|
29
29
|
- proxy0721@gmail.com
|
@@ -38,16 +38,19 @@ files:
|
|
38
38
|
- lib/redis_client/cluster/concurrent_worker/none.rb
|
39
39
|
- lib/redis_client/cluster/concurrent_worker/on_demand.rb
|
40
40
|
- lib/redis_client/cluster/concurrent_worker/pooled.rb
|
41
|
+
- lib/redis_client/cluster/error_identification.rb
|
41
42
|
- lib/redis_client/cluster/errors.rb
|
42
43
|
- lib/redis_client/cluster/key_slot_converter.rb
|
43
44
|
- lib/redis_client/cluster/node.rb
|
45
|
+
- lib/redis_client/cluster/node/base_topology.rb
|
44
46
|
- lib/redis_client/cluster/node/latency_replica.rb
|
45
47
|
- lib/redis_client/cluster/node/primary_only.rb
|
46
48
|
- lib/redis_client/cluster/node/random_replica.rb
|
47
49
|
- lib/redis_client/cluster/node/random_replica_or_primary.rb
|
48
|
-
- lib/redis_client/cluster/node/replica_mixin.rb
|
49
50
|
- lib/redis_client/cluster/node_key.rb
|
50
51
|
- lib/redis_client/cluster/normalized_cmd_name.rb
|
52
|
+
- lib/redis_client/cluster/optimistic_locking.rb
|
53
|
+
- lib/redis_client/cluster/pinning_node.rb
|
51
54
|
- lib/redis_client/cluster/pipeline.rb
|
52
55
|
- lib/redis_client/cluster/pub_sub.rb
|
53
56
|
- lib/redis_client/cluster/router.rb
|
@@ -75,7 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
78
|
- !ruby/object:Gem::Version
|
76
79
|
version: '0'
|
77
80
|
requirements: []
|
78
|
-
rubygems_version: 3.
|
81
|
+
rubygems_version: 3.5.3
|
79
82
|
signing_key:
|
80
83
|
specification_version: 4
|
81
84
|
summary: A Redis cluster client for Ruby
|
@@ -1,37 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class RedisClient
|
4
|
-
class Cluster
|
5
|
-
class Node
|
6
|
-
module ReplicaMixin
|
7
|
-
attr_reader :clients, :primary_clients
|
8
|
-
|
9
|
-
EMPTY_ARRAY = [].freeze
|
10
|
-
|
11
|
-
def initialize(replications, options, pool, _concurrent_worker, **kwargs)
|
12
|
-
@replications = replications
|
13
|
-
@primary_node_keys = @replications.keys.sort
|
14
|
-
@replica_node_keys = @replications.values.flatten.sort
|
15
|
-
@clients = build_clients(@primary_node_keys, options, pool, **kwargs)
|
16
|
-
@primary_clients = @clients.select { |k, _| @primary_node_keys.include?(k) }
|
17
|
-
end
|
18
|
-
|
19
|
-
def any_primary_node_key(seed: nil)
|
20
|
-
random = seed.nil? ? Random : Random.new(seed)
|
21
|
-
@primary_node_keys.sample(random: random)
|
22
|
-
end
|
23
|
-
|
24
|
-
private
|
25
|
-
|
26
|
-
def build_clients(primary_node_keys, options, pool, **kwargs)
|
27
|
-
options.to_h do |node_key, option|
|
28
|
-
option = option.merge(kwargs.reject { |k, _| ::RedisClient::Cluster::Node::IGNORE_GENERIC_CONFIG_KEYS.include?(k) })
|
29
|
-
config = ::RedisClient::Cluster::Node::Config.new(scale_read: !primary_node_keys.include?(node_key), **option)
|
30
|
-
client = pool.nil? ? config.new_client : config.new_pool(**pool)
|
31
|
-
[node_key, client]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|