burninator 0.6.1 → 1.0.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.
- data/README.md +8 -4
- data/lib/burninator/broadcaster.rb +1 -1
- data/lib/burninator/warmer.rb +13 -12
- metadata +2 -3
data/README.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
[](https://travis-ci.org/jpignata/burninator)
|
5
5
|
[](http://badge.fury.io/rb/burninator)
|
6
6
|
|
7
|
-
### Status:
|
7
|
+
### Status: Stable
|
8
8
|
|
9
9
|
## Summary
|
10
10
|
|
@@ -54,14 +54,18 @@ burninator = Burninator.new($redis)
|
|
54
54
|
burninator.broadcast(percentage: 25)
|
55
55
|
```
|
56
56
|
|
57
|
-
If you leave off the `redis` parameter, it will create a new connection
|
57
|
+
* If you leave off the `redis` parameter, it will create a new connection
|
58
58
|
using what's configured in the environment as `REDIS_URL`.
|
59
59
|
|
60
|
-
`percentage` will default to 5%.
|
60
|
+
* `percentage` will default to 5%.
|
61
61
|
|
62
|
-
If either `WARM_TARGET_URL` is missing or `REDIS_URL` is missing and a `redis`
|
62
|
+
* If either `WARM_TARGET_URL` is missing or `REDIS_URL` is missing and a `redis`
|
63
63
|
parameter is not provided, a `Burninator::EnvironmentError` will be raised.
|
64
64
|
|
65
|
+
* `broadcast` takes an additional parameter `ignore` which expects a regular
|
66
|
+
expression. Queries which match this regular expression will not be replayed
|
67
|
+
against the standby database.
|
68
|
+
|
65
69
|
#### Add the process in your Procfile:
|
66
70
|
|
67
71
|
```ruby
|
@@ -34,7 +34,7 @@ class Burninator
|
|
34
34
|
def publish?(sql)
|
35
35
|
return false unless sql =~ /\Aselect /i
|
36
36
|
return false if sql =~ / for (update|share)\z/i
|
37
|
-
return false if sql =~ @ignore
|
37
|
+
return false if sql =~ @ignore
|
38
38
|
|
39
39
|
SecureRandom.random_number(100 / @percentage) == 0
|
40
40
|
end
|
data/lib/burninator/warmer.rb
CHANGED
@@ -8,18 +8,7 @@ class Burninator
|
|
8
8
|
|
9
9
|
def run
|
10
10
|
trap_signals
|
11
|
-
|
12
|
-
begin
|
13
|
-
@redis.subscribe(@channel) do |on|
|
14
|
-
on.message do |_, serialized|
|
15
|
-
event = Marshal.load(serialized)
|
16
|
-
process(event)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
rescue Errno::ECONNRESET
|
20
|
-
Rails.logger.error("Redis connection reset; resubscribing...")
|
21
|
-
retry
|
22
|
-
end
|
11
|
+
subscribe
|
23
12
|
end
|
24
13
|
|
25
14
|
private
|
@@ -29,6 +18,18 @@ class Burninator
|
|
29
18
|
trap(:TERM) { abort }
|
30
19
|
end
|
31
20
|
|
21
|
+
def subscribe
|
22
|
+
@redis.subscribe(@channel) do |on|
|
23
|
+
on.message do |_, serialized|
|
24
|
+
event = Marshal.load(serialized)
|
25
|
+
process(event)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
rescue Errno::ECONNRESET
|
29
|
+
Rails.logger.error("Redis connection reset; resubscribing...")
|
30
|
+
retry
|
31
|
+
end
|
32
|
+
|
32
33
|
def process(event)
|
33
34
|
query = event[:sql].squish
|
34
35
|
binds = event[:binds]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: burninator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -101,4 +101,3 @@ signing_key:
|
|
101
101
|
specification_version: 3
|
102
102
|
summary: Keep your follower database warm
|
103
103
|
test_files: []
|
104
|
-
has_rdoc:
|