redis_failover-rails 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +49 -4
- data/lib/redis_failover-rails/version.rb +1 -1
- metadata +2 -3
- data/config/initializers/passenger.rb +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 815798df4dad8e2808c91aa05a7eb4113bbe43d3
|
4
|
+
data.tar.gz: a369751f3867d1cd900d9fbd23a5448f965e7c39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 819937fdc09c7dedab7f77c5504c701941aaaa709b99ee0198c43cbc16ffcd9657e06c8138886508eeb2cf41eadb5b88e4a4bf92b387e614742ce9eb1df20e7c
|
7
|
+
data.tar.gz: 70c10548893ab1e8caae9ae0a34465b0180e25f6f796b656ecee8f7ad81d336bc97b78c5254716d3a104e559e3664b4f546c2a6b5770a18c6693d04b3419edb9
|
data/README.md
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
[ ](https://codeship.io/projects/22198)
|
4
4
|
[](https://codeclimate.com/github/surfdome/redis_failover-rails)
|
5
|
+
[](http://badge.fury.io/rb/redis_failover-rails)
|
5
6
|
|
6
7
|
An ActiveSupport::Cache store using redis_failover (a zookeeper based implementation of HA redis) for Rails apps.
|
7
8
|
|
@@ -22,12 +23,29 @@ Just don't specify zkservers in the config file.
|
|
22
23
|
Just add the dependency to your Gemfile...
|
23
24
|
|
24
25
|
# Gemfile
|
25
|
-
gem 'redis_failover-rails'
|
26
|
+
gem 'redis_failover-rails'
|
26
27
|
|
27
28
|
and run bundle install.
|
28
29
|
|
29
30
|
bundle install
|
30
31
|
|
32
|
+
**NOTE:** If you are running passenger or unicorn, you definitely want to add this to your `config/initializers/passenger.rb` of your app.
|
33
|
+
|
34
|
+
This is **_THIS IS VERY IMPORTANT IN PRODUCTION ENVIRONMENTS!!_**
|
35
|
+
|
36
|
+
if defined?(PhusionPassenger)
|
37
|
+
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
38
|
+
if forked
|
39
|
+
# We're in smart spawning mode.
|
40
|
+
|
41
|
+
# Reset redis failover clients
|
42
|
+
RedisFactory.reconnect
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
This generates a reconnect after the app is forked so the redis clients get reset.
|
48
|
+
|
31
49
|
## Usage
|
32
50
|
In your application.rb (or environment), you should use something like:
|
33
51
|
|
@@ -45,14 +63,16 @@ For running the tests, just:
|
|
45
63
|
bundle exec rake
|
46
64
|
|
47
65
|
## Configuration
|
48
|
-
In order to define your redis and redis_failover configurations, you just need to use the `redis.yml` config file
|
66
|
+
In order to define your redis and redis_failover configurations, you just need to use the `redis.yml` config file
|
67
|
+
|
68
|
+
This is mandatory at the moment of integrating the gem with your Rails app, there are no defaults. The existing config file in the repo is used for tests only, when you run the gem inside the Rails app, it tries to find the proper `redis.yml` file and if it doesn't exist, the app just doesn't start.
|
49
69
|
|
50
70
|
This follows a format like this:
|
51
71
|
|
52
72
|
environment:
|
53
73
|
instance:
|
54
|
-
parameter1:
|
55
|
-
parameter2:
|
74
|
+
parameter1: value1
|
75
|
+
parameter2: value2
|
56
76
|
|
57
77
|
This gem automatically selects a redis_failover client if you define `:zkservers` in the config file. If not, it just uses the standard redis client.
|
58
78
|
|
@@ -80,6 +100,31 @@ Typical configuration parameters for standard redis clients are:
|
|
80
100
|
|
81
101
|
Please keep in mind that this options are not validated, just passed to the client configuration.
|
82
102
|
|
103
|
+
Basic `redis.yml` examples:
|
104
|
+
|
105
|
+
# Standard redis
|
106
|
+
development:
|
107
|
+
cache:
|
108
|
+
host: localhost
|
109
|
+
port: 6379
|
110
|
+
db: 1
|
111
|
+
|
112
|
+
# HA redis_failover in development
|
113
|
+
production:
|
114
|
+
hacache:
|
115
|
+
thread_safe: true
|
116
|
+
zkservers: localhost:2181, localhost:2182, localhost:2183
|
117
|
+
db: 1
|
118
|
+
znode_path: /redis_failover #sometimes required...
|
119
|
+
|
120
|
+
# HA redis_failover for a production environment
|
121
|
+
production:
|
122
|
+
hacache:
|
123
|
+
thread_safe: true
|
124
|
+
zkservers: zk-1:2181, zk-2:2181, zk-3:2181
|
125
|
+
db: 1
|
126
|
+
znode_path: /redis_failover #sometimes required...
|
127
|
+
|
83
128
|
## License
|
84
129
|
This gem is released with MIT licensing. Please see [LICENSE](https://github.com/surfdome/redis_failover-rails/blob/master/LICENSE) for details.
|
85
130
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redis_failover-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jose Pettoruti - Surfdome.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis_failover
|
@@ -183,7 +183,6 @@ files:
|
|
183
183
|
- LICENSE
|
184
184
|
- README.md
|
185
185
|
- Rakefile
|
186
|
-
- config/initializers/passenger.rb
|
187
186
|
- config/redis.yml
|
188
187
|
- lib/active_support/cache/redis_cache_store.rb
|
189
188
|
- lib/redis_factory.rb
|
@@ -1,12 +0,0 @@
|
|
1
|
-
if defined?(PhusionPassenger)
|
2
|
-
PhusionPassenger.on_event(:starting_worker_process) do |forked|
|
3
|
-
if forked
|
4
|
-
# We're in smart spawning mode.
|
5
|
-
|
6
|
-
# Reset redis failover clients
|
7
|
-
RedisFactory.reconnect
|
8
|
-
else
|
9
|
-
# We're in conservative spawning mode. We don't need to do anything.
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|