burninator 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -28,6 +28,7 @@ traffic, its caches should keep warm and ready for failover.
28
28
  ## Requirements
29
29
 
30
30
  * Rails application (only tested against 3.2.12)
31
+ * Ruby 1.9+
31
32
  * Redis
32
33
 
33
34
  ## Installation
@@ -50,7 +51,7 @@ gem "burninator"
50
51
 
51
52
  ```ruby
52
53
  burninator = Burninator.new($redis)
53
- burninator.broadcast(:percentage => 25)
54
+ burninator.broadcast(percentage: 25)
54
55
  ```
55
56
 
56
57
  If you leave off the `redis` parameter, it will create a new connection
@@ -58,7 +59,7 @@ using what's configured in the environment as `REDIS_URL`.
58
59
 
59
60
  `percentage` will default to 5%.
60
61
 
61
- 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`
62
63
  parameter is not provided, a `Burninator::EnvironmentError` will be raised.
63
64
 
64
65
  #### Add the process in your Procfile:
data/lib/burninator.rb CHANGED
@@ -13,18 +13,13 @@ class Burninator
13
13
  end
14
14
 
15
15
  def warm
16
- trap_signals
17
-
18
16
  Burninator::Warmer.new(redis, channel, database).run
19
17
  end
20
18
 
21
19
  def broadcast(options = {})
22
- percentage = options.fetch(:percentage, DEFAULT_PERCENTAGE)
23
- ignore = options[:ignore]
24
-
25
20
  broadcaster = Burninator::Broadcaster.new(redis, channel,
26
- :ignore => ignore,
27
- :percentage => percentage
21
+ percentage: options.fetch(:percentage, DEFAULT_PERCENTAGE),
22
+ ignore: options[:ignore]
28
23
  )
29
24
 
30
25
  broadcaster.run
@@ -36,13 +31,8 @@ class Burninator
36
31
 
37
32
  private
38
33
 
39
- def trap_signals
40
- trap(:INT) { abort }
41
- trap(:TERM) { abort }
42
- end
43
-
44
34
  def redis
45
- @redis ||= Redis.new(:url => redis_url)
35
+ @redis ||= Redis.new(url: redis_url)
46
36
  end
47
37
 
48
38
  def database
@@ -7,16 +7,28 @@ class Burninator
7
7
  end
8
8
 
9
9
  def run
10
- @redis.subscribe(@channel) do |on|
11
- on.message do |_, serialized|
12
- event = Marshal.load(serialized)
13
- process(event)
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
14
18
  end
19
+ rescue Errno::ECONNRESET
20
+ Rails.logger.error("Redis connection reset; resubscribing...")
21
+ retry
15
22
  end
16
23
  end
17
24
 
18
25
  private
19
26
 
27
+ def trap_signals
28
+ trap(:INT) { abort }
29
+ trap(:TERM) { abort }
30
+ end
31
+
20
32
  def process(event)
21
33
  query = event[:sql].squish
22
34
  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.6.0
4
+ version: 0.6.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: