redis_failover-rails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +45 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +100 -0
- data/Rakefile +22 -0
- data/config/initializers/passenger.rb +12 -0
- data/config/redis.yml +33 -0
- data/lib/active_support/cache/redis_cache_store.rb +167 -0
- data/lib/redis_factory.rb +113 -0
- data/lib/redis_failover-rails/version.rb +3 -0
- data/redis_failover-rails.gemspec +38 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +83 -0
- data/test/dummy/config/environments/test.rb +45 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/test_helper.rb +62 -0
- data/test/unit/active_support/cache/redis_cache_store_test.rb +178 -0
- data/test/unit/redis_factory_test.rb +111 -0
- metadata +301 -0
@@ -0,0 +1,111 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../test_helper.rb')
|
2
|
+
|
3
|
+
class RedisFactoryTest < ActiveSupport::TestCase
|
4
|
+
|
5
|
+
setup do
|
6
|
+
@oldconf = RedisFactory.class_variable_get("@@configuration")
|
7
|
+
RedisFactory.class_variable_set("@@configuration", nil)
|
8
|
+
@oldclients = RedisFactory.class_variable_get("@@clients")
|
9
|
+
RedisFactory.class_variable_set("@@clients", {})
|
10
|
+
end
|
11
|
+
|
12
|
+
teardown do
|
13
|
+
RedisFactory.class_variable_set("@@configuration", @oldconf)
|
14
|
+
RedisFactory.class_variable_set("@@clients", @oldclients)
|
15
|
+
end
|
16
|
+
|
17
|
+
context "#configuration" do
|
18
|
+
should "read in redis.yml" do
|
19
|
+
assert_equal(
|
20
|
+
{ :myredisdb => {
|
21
|
+
"db" => 1,
|
22
|
+
"host" => "localhost",
|
23
|
+
"port" => 6379,
|
24
|
+
"thread_safe" => true },
|
25
|
+
:cache => {
|
26
|
+
"db" => 2,
|
27
|
+
"host" => "localhost",
|
28
|
+
"port" => 6379,
|
29
|
+
"thread_safe" => true },
|
30
|
+
:hacache => {
|
31
|
+
"db" => 8,
|
32
|
+
"thread_safe" => true,
|
33
|
+
"zkservers" => "localhost:2181" }
|
34
|
+
},
|
35
|
+
RedisFactory.configuration)
|
36
|
+
end
|
37
|
+
|
38
|
+
# should "read in redis.yml for different env" do
|
39
|
+
# skip
|
40
|
+
# assert_equal({:myredisdb => {:host=>"bar"}}, RedisFactory.configuration)
|
41
|
+
# end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
context "#connect" do
|
46
|
+
should "return client for symbol" do
|
47
|
+
assert_equal 1, RedisFactory.connect(:myredisdb).client.db
|
48
|
+
assert_equal 2, RedisFactory.connect(:cache).client.db
|
49
|
+
end
|
50
|
+
|
51
|
+
should "reuse client for same symbol" do
|
52
|
+
assert_equal RedisFactory.connect(:myredisdb), RedisFactory.connect(:myredisdb)
|
53
|
+
end
|
54
|
+
|
55
|
+
should "return standard redis client if no zkservers" do
|
56
|
+
client = mock()
|
57
|
+
::Redis.expects(:new).returns(client)
|
58
|
+
assert_equal client, RedisFactory.connect(:myredisdb)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "return failover redis client if zkservers present" do
|
62
|
+
client = mock()
|
63
|
+
::RedisFailover::Client.expects(:new).returns(client)
|
64
|
+
assert_equal client, RedisFactory.connect(:hacache)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
context "#disconnect" do
|
70
|
+
should "disconnect specific client" do
|
71
|
+
myredisdb_client = RedisFactory.connect(:myredisdb)
|
72
|
+
cache_client = RedisFactory.connect(:cache)
|
73
|
+
|
74
|
+
myredisdb_client.expects(:quit)
|
75
|
+
cache_client.expects(:quit).never
|
76
|
+
RedisFactory.disconnect(:myredisdb)
|
77
|
+
end
|
78
|
+
|
79
|
+
should "disconnect all clients" do
|
80
|
+
myredisdb_client = RedisFactory.connect(:myredisdb)
|
81
|
+
cache_client = RedisFactory.connect(:cache)
|
82
|
+
|
83
|
+
myredisdb_client.expects(:quit)
|
84
|
+
cache_client.expects(:quit)
|
85
|
+
RedisFactory.disconnect
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
|
90
|
+
context "#reconnect" do
|
91
|
+
should "reconnect specific client" do
|
92
|
+
myredisdb_client = RedisFactory.connect(:myredisdb)
|
93
|
+
cache_client = RedisFactory.connect(:cache)
|
94
|
+
|
95
|
+
myredisdb_client.expects(:client).returns(mock('redis', :reconnect => nil))
|
96
|
+
cache_client.expects(:client).never
|
97
|
+
RedisFactory.reconnect(:myredisdb)
|
98
|
+
end
|
99
|
+
|
100
|
+
should "reconnect all clients" do
|
101
|
+
myredisdb_client = RedisFactory.connect(:myredisdb)
|
102
|
+
cache_client = RedisFactory.connect(:cache)
|
103
|
+
|
104
|
+
myredisdb_client.expects(:client).returns(mock('redis', :reconnect => nil))
|
105
|
+
cache_client.expects(:client).returns(mock('redis', :reconnect => nil))
|
106
|
+
RedisFactory.reconnect
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
end
|
metadata
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redis_failover-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jose Pettoruti - Surfdome.com
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redis_failover
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.0.2
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.0'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.0.2
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '10'
|
40
|
+
type: :development
|
41
|
+
prerelease: false
|
42
|
+
version_requirements: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '10'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: bundler
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '1.3'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1.3'
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: mocha
|
63
|
+
requirement: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
type: :development
|
69
|
+
prerelease: false
|
70
|
+
version_requirements: !ruby/object:Gem::Requirement
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: test-unit
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
- !ruby/object:Gem::Dependency
|
90
|
+
name: shoulda-context
|
91
|
+
requirement: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
type: :development
|
97
|
+
prerelease: false
|
98
|
+
version_requirements: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: awesome_print
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: activesupport
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '4'
|
124
|
+
type: :runtime
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '4'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: actionpack
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '4'
|
138
|
+
type: :runtime
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '4'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rails
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '4.1'
|
152
|
+
type: :runtime
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '4.1'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: sqlite3
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
description: An ActiveSupport::Cache store using redis_failover (a zookeeper based
|
174
|
+
implementation of HA redis) for Rails apps.
|
175
|
+
email:
|
176
|
+
- jose.pettoruti@surfdome.com
|
177
|
+
executables: []
|
178
|
+
extensions: []
|
179
|
+
extra_rdoc_files: []
|
180
|
+
files:
|
181
|
+
- ".gitignore"
|
182
|
+
- Gemfile
|
183
|
+
- LICENSE
|
184
|
+
- README.md
|
185
|
+
- Rakefile
|
186
|
+
- config/initializers/passenger.rb
|
187
|
+
- config/redis.yml
|
188
|
+
- lib/active_support/cache/redis_cache_store.rb
|
189
|
+
- lib/redis_factory.rb
|
190
|
+
- lib/redis_failover-rails/version.rb
|
191
|
+
- redis_failover-rails.gemspec
|
192
|
+
- test/dummy/README.rdoc
|
193
|
+
- test/dummy/Rakefile
|
194
|
+
- test/dummy/app/assets/images/.keep
|
195
|
+
- test/dummy/app/assets/javascripts/application.js
|
196
|
+
- test/dummy/app/assets/stylesheets/application.css
|
197
|
+
- test/dummy/app/controllers/application_controller.rb
|
198
|
+
- test/dummy/app/controllers/concerns/.keep
|
199
|
+
- test/dummy/app/helpers/application_helper.rb
|
200
|
+
- test/dummy/app/mailers/.keep
|
201
|
+
- test/dummy/app/models/.keep
|
202
|
+
- test/dummy/app/models/concerns/.keep
|
203
|
+
- test/dummy/app/views/layouts/application.html.erb
|
204
|
+
- test/dummy/bin/bundle
|
205
|
+
- test/dummy/bin/rails
|
206
|
+
- test/dummy/bin/rake
|
207
|
+
- test/dummy/config.ru
|
208
|
+
- test/dummy/config/application.rb
|
209
|
+
- test/dummy/config/boot.rb
|
210
|
+
- test/dummy/config/database.yml
|
211
|
+
- test/dummy/config/environment.rb
|
212
|
+
- test/dummy/config/environments/development.rb
|
213
|
+
- test/dummy/config/environments/production.rb
|
214
|
+
- test/dummy/config/environments/test.rb
|
215
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
216
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
217
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
218
|
+
- test/dummy/config/initializers/inflections.rb
|
219
|
+
- test/dummy/config/initializers/mime_types.rb
|
220
|
+
- test/dummy/config/initializers/session_store.rb
|
221
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
222
|
+
- test/dummy/config/locales/en.yml
|
223
|
+
- test/dummy/config/routes.rb
|
224
|
+
- test/dummy/config/secrets.yml
|
225
|
+
- test/dummy/lib/assets/.keep
|
226
|
+
- test/dummy/log/.keep
|
227
|
+
- test/dummy/public/404.html
|
228
|
+
- test/dummy/public/422.html
|
229
|
+
- test/dummy/public/500.html
|
230
|
+
- test/dummy/public/favicon.ico
|
231
|
+
- test/test_helper.rb
|
232
|
+
- test/unit/active_support/cache/redis_cache_store_test.rb
|
233
|
+
- test/unit/redis_factory_test.rb
|
234
|
+
homepage: https://github.com/surfdome/redis_failover-rails
|
235
|
+
licenses:
|
236
|
+
- MIT
|
237
|
+
metadata: {}
|
238
|
+
post_install_message:
|
239
|
+
rdoc_options: []
|
240
|
+
require_paths:
|
241
|
+
- lib
|
242
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ">="
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: '0'
|
247
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
requirements: []
|
253
|
+
rubyforge_project:
|
254
|
+
rubygems_version: 2.2.2
|
255
|
+
signing_key:
|
256
|
+
specification_version: 4
|
257
|
+
summary: An ActiveSupport::Cache store using redis_failover
|
258
|
+
test_files:
|
259
|
+
- test/dummy/README.rdoc
|
260
|
+
- test/dummy/Rakefile
|
261
|
+
- test/dummy/app/assets/images/.keep
|
262
|
+
- test/dummy/app/assets/javascripts/application.js
|
263
|
+
- test/dummy/app/assets/stylesheets/application.css
|
264
|
+
- test/dummy/app/controllers/application_controller.rb
|
265
|
+
- test/dummy/app/controllers/concerns/.keep
|
266
|
+
- test/dummy/app/helpers/application_helper.rb
|
267
|
+
- test/dummy/app/mailers/.keep
|
268
|
+
- test/dummy/app/models/.keep
|
269
|
+
- test/dummy/app/models/concerns/.keep
|
270
|
+
- test/dummy/app/views/layouts/application.html.erb
|
271
|
+
- test/dummy/bin/bundle
|
272
|
+
- test/dummy/bin/rails
|
273
|
+
- test/dummy/bin/rake
|
274
|
+
- test/dummy/config.ru
|
275
|
+
- test/dummy/config/application.rb
|
276
|
+
- test/dummy/config/boot.rb
|
277
|
+
- test/dummy/config/database.yml
|
278
|
+
- test/dummy/config/environment.rb
|
279
|
+
- test/dummy/config/environments/development.rb
|
280
|
+
- test/dummy/config/environments/production.rb
|
281
|
+
- test/dummy/config/environments/test.rb
|
282
|
+
- test/dummy/config/initializers/backtrace_silencers.rb
|
283
|
+
- test/dummy/config/initializers/cookies_serializer.rb
|
284
|
+
- test/dummy/config/initializers/filter_parameter_logging.rb
|
285
|
+
- test/dummy/config/initializers/inflections.rb
|
286
|
+
- test/dummy/config/initializers/mime_types.rb
|
287
|
+
- test/dummy/config/initializers/session_store.rb
|
288
|
+
- test/dummy/config/initializers/wrap_parameters.rb
|
289
|
+
- test/dummy/config/locales/en.yml
|
290
|
+
- test/dummy/config/routes.rb
|
291
|
+
- test/dummy/config/secrets.yml
|
292
|
+
- test/dummy/lib/assets/.keep
|
293
|
+
- test/dummy/log/.keep
|
294
|
+
- test/dummy/public/404.html
|
295
|
+
- test/dummy/public/422.html
|
296
|
+
- test/dummy/public/500.html
|
297
|
+
- test/dummy/public/favicon.ico
|
298
|
+
- test/test_helper.rb
|
299
|
+
- test/unit/active_support/cache/redis_cache_store_test.rb
|
300
|
+
- test/unit/redis_factory_test.rb
|
301
|
+
has_rdoc:
|