redis-cluster-client 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ad96d02be39509b6df863c42e630940f053b6aea6cb478fe1fbec26fb5464e7c
4
- data.tar.gz: '09983aedc4498a48f0fa2d7882e0df4b0998cd3ffd9d2ef13940abe50606a3e9'
3
+ metadata.gz: 4339be83a679ef61e9d9a98e26cd2dd52b58b56eaa852a53c8f0f01ef1987396
4
+ data.tar.gz: ac7ea102f9d5a711ee495a36c844443027b39d2c64e0d9177d419d00e1fa0de0
5
5
  SHA512:
6
- metadata.gz: '098a5674c2aa837fc26287c599b8dfd3d849af73ba5267a63b0741411c60312b15a819dc8fe0acd48e5a0d1696f610bb1c7196461ac12c6a49000a13c702836b'
7
- data.tar.gz: 5134b1fd9f789166f29555abece7ef888c9a4c9e73a3ea04c0e06ed93a872ca908fa9a17a0f86746c7fe532d14a8a307f457115cf9b6f989c24d2b26938f38e4
6
+ metadata.gz: 268000fa3691afc08d969b35cf8ac90221e96ffb41db59c63d9737e9ebed3d978f84f36ba4ee91ceb4bb88c957c3d2ecead676bc7b6c7a4411598969213e269c
7
+ data.tar.gz: 1a44f77bdd4202f327025d3fa0d0a3b65b577332cd714f787159c8ba41f20f5b3c8b058b5c48aab74f5d0a7b3ec4638f227b5f205ed07c8e32dba4c71220695b
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'redis_client'
4
+ require 'redis_client/config'
4
5
  require 'redis_client/cluster/errors'
5
6
 
6
7
  class RedisClient
@@ -11,6 +12,19 @@ class RedisClient
11
12
  SLOT_SIZE = 16_384
12
13
  ReloadNeeded = Class.new(::RedisClient::Error)
13
14
 
15
+ class Config < ::RedisClient::Config
16
+ def initialize(scale_read: false, **kwargs)
17
+ @scale_read = scale_read
18
+ super(**kwargs)
19
+ end
20
+
21
+ def build_connection_prelude
22
+ prelude = super.dup
23
+ prelude << ['READONLY'] if @scale_read
24
+ prelude.freeze
25
+ end
26
+ end
27
+
14
28
  class << self
15
29
  def load_info(options, **kwargs)
16
30
  tmp_nodes = ::RedisClient::Cluster::Node.new(options, **kwargs)
@@ -143,18 +157,6 @@ class RedisClient
143
157
  !(@replications.nil? || @replications.size.zero?) && @replications[node_key].size.zero?
144
158
  end
145
159
 
146
- def build_clients(options, pool, **kwargs)
147
- options.filter_map do |node_key, option|
148
- next if replica_disabled? && replica?(node_key)
149
-
150
- config = ::RedisClient.config(**option)
151
- client = pool.nil? ? config.new_client(**kwargs) : config.new_pool(**pool, **kwargs)
152
- client.call('READONLY') if replica?(node_key) # FIXME: Send every pooled conns
153
-
154
- [node_key, client]
155
- end.to_h
156
- end
157
-
158
160
  def build_slot_node_mappings(node_info)
159
161
  slots = Array.new(SLOT_SIZE)
160
162
  node_info.each do |info|
@@ -175,6 +177,17 @@ class RedisClient
175
177
  end
176
178
  end
177
179
 
180
+ def build_clients(options, pool, **kwargs)
181
+ options.filter_map do |node_key, option|
182
+ next if replica_disabled? && replica?(node_key)
183
+
184
+ config = ::RedisClient::Cluster::Node::Config.new(scale_read: replica?(node_key), **option)
185
+ client = pool.nil? ? config.new_client(**kwargs) : config.new_pool(**pool, **kwargs)
186
+
187
+ [node_key, client]
188
+ end.to_h
189
+ end
190
+
178
191
  def try_map # rubocop:disable Metrics/MethodLength
179
192
  errors = {}
180
193
  results = {}
@@ -2,14 +2,11 @@
2
2
 
3
3
  require 'uri'
4
4
  require 'redis_client'
5
- require 'redis_client/config'
6
5
  require 'redis_client/cluster'
7
6
  require 'redis_client/cluster/node_key'
8
7
 
9
8
  class RedisClient
10
9
  class ClusterConfig
11
- include ::RedisClient::Config::Common
12
-
13
10
  DEFAULT_SCHEME = 'redis'
14
11
  SECURE_SCHEME = 'rediss'
15
12
  VALID_SCHEMES = [DEFAULT_SCHEME, SECURE_SCHEME].freeze
@@ -23,7 +20,6 @@ class RedisClient
23
20
  add_common_node_config_if_needed(@client_config, @node_configs, :ssl)
24
21
  add_common_node_config_if_needed(@client_config, @node_configs, :username)
25
22
  add_common_node_config_if_needed(@client_config, @node_configs, :password)
26
- super(**@client_config)
27
23
  end
28
24
 
29
25
  def inspect
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
- - Taishi
8
- - Kasuga
7
+ - Taishi Kasuga
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2022-06-11 00:00:00.000000000 Z
11
+ date: 2022-06-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: redis-client
@@ -61,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
60
  - !ruby/object:Gem::Version
62
61
  version: '0'
63
62
  requirements: []
64
- rubygems_version: 3.3.13
63
+ rubygems_version: 3.3.15
65
64
  signing_key:
66
65
  specification_version: 4
67
66
  summary: A Redis cluster client for Ruby