Skip to content

Commit 0ffebf8

Browse files
committed
Roughly porting
1 parent cede9e3 commit 0ffebf8

18 files changed

+1251
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.bundle
2+
*.gem
3+
Gemfile.lock

.rubocop.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
require:
3+
- rubocop-performance
4+
- rubocop-rake
5+
- rubocop-minitest
6+
7+
# https://rubocop.readthedocs.io/en/latest/
8+
AllCops:
9+
TargetRubyVersion: 2.7
10+
DisplayCopNames: true
11+
NewCops: enable
12+
13+
Metrics/AbcSize:
14+
Exclude:
15+
- 'test/**/*'
16+
17+
Metrics/ClassLength:
18+
Max: 400
19+
20+
Metrics/MethodLength:
21+
Exclude:
22+
- 'test/**/*'
23+
24+
Layout/LineLength:
25+
Max: 200
26+
27+
Style/NumericPredicate:
28+
Enabled: false
29+
30+
Style/FormatStringToken:
31+
Enabled: false
32+
33+
Style/Documentation:
34+
Enabled: false
35+
36+
Gemspec/RequiredRubyVersion:
37+
Enabled: false

Gemfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# frozen_string_literal: true
2+
3+
source 'https://rubygems.org'
4+
gemspec name: 'redis-cluster-client'
5+
6+
gem 'minitest'
7+
gem 'rake'
8+
gem 'rubocop'
9+
gem 'rubocop-minitest', require: false
10+
gem 'rubocop-performance', require: false
11+
gem 'rubocop-rake', require: false

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 redis-rb
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
[![Gem Version](https://badge.fury.io/rb/redis-cluster-client.svg)](https://badge.fury.io/rb/redis-cluster-client)
2+
13
TODO
4+
===============================================================================
5+
6+
```ruby
7+
cli = RedisClient.cluster(nodes: %w[redis://127.0.0.1:7000], replica: false).new_client
8+
9+
cli.call('PING')
10+
#=> PONG
11+
```

Rakefile

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# frozen_string_literal: true
2+
3+
require 'rake/testtask'
4+
5+
task default: :test
6+
7+
desc 'execute all test'
8+
Rake::TestTask.new :test do |t|
9+
t.libs << :test
10+
t.libs << :lib
11+
t.test_files = Dir['test/**/test_*.rb']
12+
end

bin/console

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'irb'
5+
require 'bundler/setup'
6+
require 'redis_client'
7+
require 'redis_cluster_client'
8+
9+
IRB.start(File.expand_path('..', __dir__))

docs/CLASS_DIAGRAM.md

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,250 @@
1+
```mermaid
2+
classDiagram
3+
class RedisClient {
4+
+self.register_driver()
5+
+self.driver()
6+
+self.default_driver()
7+
+self.default_driver=()
8+
+self.config()
9+
+self.sentinel()
10+
+self.new()
11+
+self.register(middleware)
12+
+initialize()
13+
+size()
14+
+with()
15+
+timeout=()
16+
+read_timeout=()
17+
+write_timeout=()
18+
+pubsub()
19+
+call()
20+
+call_once()
21+
+blocking_call()
22+
+scan()
23+
+sscan()
24+
+hscan()
25+
+zscan()
26+
+connected?()
27+
+close()
28+
+pipelined()
29+
+multi()
30+
}
31+
32+
class module_RedisClient_Common {
33+
+config()
34+
+id()
35+
+connect_timeout()
36+
+connect_timeout=()
37+
+read_timeout()
38+
+read_timeout=()
39+
+write_timeout()
40+
+write_timeout=()
41+
+timeout=()
42+
}
43+
44+
class RedisClient_PubSub {
45+
+initialize()
46+
+call()
47+
+close()
48+
+next_event()
49+
}
50+
51+
class RedisClient_Multi {
52+
+initialize()
53+
+call()
54+
+call_once()
55+
}
56+
57+
class RedisClient_Pipeline {
58+
+initialize()
59+
+blocking_call()
60+
}
61+
62+
class RedisClient_RubyConnection_BufferedIO {
63+
+read_timeout()
64+
+read_timeout=()
65+
+write_timeout()
66+
+write_timeout=()
67+
+initialize()
68+
+close()
69+
+closed?()
70+
+eof?()
71+
+with_timeout()
72+
+skip()
73+
+write()
74+
+getbyte()
75+
+gets_chomp()
76+
+read_chomp()
77+
}
78+
79+
class module_RedisClient_RESP3 {
80+
+self.dump()
81+
+self.load()
82+
+self.new_buffer()
83+
+self.dump_any()
84+
+self.dump_array()
85+
+self.dump_set()
86+
+self.dump_hash()
87+
+self.dump_numeric()
88+
+self.dump_string()
89+
+self.parse()
90+
+self.parse_string()
91+
+self.parse_error()
92+
+self.parse_boolean()
93+
+self.parse_array()
94+
+self.parse_set()
95+
+self.parse_map()
96+
+self.parse_push()
97+
+self.parse_sequence()
98+
+self.parse_integer()
99+
+self.parse_double()
100+
+self.parse_null()
101+
+self.parse_blob()
102+
+self.parse_verbatim_string()
103+
}
104+
105+
class module_RedisClient_CommandBuilder {
106+
+self.generate!()
107+
}
108+
109+
class RedisClient_Config {
110+
+host()
111+
+port()
112+
+path()
113+
+initialize()
114+
}
115+
116+
class module_RedisClient_Config_Common {
117+
+db()
118+
+username()
119+
+password()
120+
+id()
121+
+ssl()
122+
+ssl?()
123+
+ssl_params()
124+
+command_builder()
125+
+connect_timeout()
126+
+read_timeout()
127+
+write_timeout()
128+
+driver()
129+
+connection_prelude()
130+
+initialize()
131+
+sentinel?()
132+
+new_pool()
133+
+new_client()
134+
+retry_connecting?()
135+
+ssl_context()
136+
}
137+
138+
class RedisClient_SentinelConfig {
139+
+initialize()
140+
+sentinels()
141+
+reset()
142+
+host()
143+
+port()
144+
+path()
145+
+retry_connecting?()
146+
+sentinel?()
147+
+check_role!()
148+
}
149+
150+
class module_RedisClient_ConnectionMixin {
151+
+call()
152+
+call_pipelined()
153+
}
154+
155+
class RedisClient_RubyConnection {
156+
+self.ssl_context()
157+
+initialize()
158+
+connected?()
159+
+close()
160+
+read_timeout=()
161+
+write_timeout=()
162+
+write()
163+
+write_multi()
164+
+read()
165+
}
166+
167+
class module_RedisClient_Decorator {
168+
+self.create()
169+
}
170+
171+
class module_RedisClient_Decorator_CommandsMixin {
172+
+initialize()
173+
+call()
174+
+call_once()
175+
+blocking_call()
176+
}
177+
178+
class RedisClient_Decorator_Pipeline {
179+
}
180+
181+
class RedisClient_Decorator_Client {
182+
+initialize()
183+
+with()
184+
+pipelined()
185+
+multi()
186+
+close()
187+
+scan()
188+
+hscan()
189+
+sscan()
190+
+zscan()
191+
+id()
192+
+config()
193+
+size()
194+
+connect_timeout()
195+
+read_timeout()
196+
+write_timeout()
197+
+timeout=()
198+
+connect_timeout=()
199+
+read_timeout=()
200+
+write_timeout=()
201+
}
202+
203+
class module_RedisClient_Middlewares {
204+
+self.call()
205+
+self.call_pipelined()
206+
}
207+
208+
class RedisClient_Pooled {
209+
+initialize()
210+
+with()
211+
+close()
212+
+size()
213+
+pipelined()
214+
+multi()
215+
+pubsub()
216+
+call()
217+
+call_once()
218+
+blocking_call()
219+
+scan()
220+
+sscan()
221+
+hscan()
222+
+zscan()
223+
}
224+
225+
RedisClient ..|> module_RedisClient_Common : include
226+
RedisClient ..> RedisClient_PubSub : new
227+
RedisClient ..> RedisClient_Multi : new
228+
RedisClient ..> RedisClient_Pipeline : new
229+
RedisClient ..> module_RedisClient_Middlewares : call
230+
RedisClient ..> RedisClient_RubyConnection : new
231+
RedisClient ..> RedisClient_Config : new
232+
RedisClient ..> RedisClient_SentinelConfig : new
233+
RedisClient ..> module_RedisClient_CommandBuilder : call
234+
RedisClient_Multi <|.. RedisClient_Pipeline : extend
235+
236+
RedisClient_Config ..|> module_RedisClient_Config_Common : include
237+
RedisClient_SentinelConfig ..|> module_RedisClient_Config_Common : include
238+
module_RedisClient_Config_Common ..> RedisClient_Pooled : new
239+
240+
module_RedisClient_Decorator ..> RedisClient_Decorator_Pipeline : new
241+
module_RedisClient_Decorator ..> RedisClient_Decorator_Client : new
242+
RedisClient_Decorator_Pipeline ..|> module_RedisClient_Decorator_CommandsMixin : include
243+
RedisClient_Decorator_Client ..|> module_RedisClient_Decorator_CommandsMixin : include
244+
245+
RedisClient_Pooled ..|> module_RedisClient_Common : include
246+
247+
RedisClient_RubyConnection ..|> module_RedisClient_ConnectionMixin : include
248+
RedisClient_RubyConnection ..> RedisClient_RubyConnection_BufferedIO : new
249+
RedisClient_RubyConnection ..> module_RedisClient_RESP3 : call
250+
```

0 commit comments

Comments
 (0)