anschel 0.7.10 → 0.7.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5d32db0a5fe08817a91ac24c3d3e4cc57b53ce01
4
- data.tar.gz: 4df5ae73011b3c6a8952b6c6366007f24241e842
3
+ metadata.gz: cdf130bb128d999dc9450067c9633f83d9526c38
4
+ data.tar.gz: 23e6e0352befe82127788fee394d833dcc2abbe7
5
5
  SHA512:
6
- metadata.gz: 73111befe962052809308f788bbb2ccf306992fbc0cbc2360f65c6ee107002c75e473768f8c970b211ee219d189671b72c8c1d0892c23c5f14fe66f384b1c41f
7
- data.tar.gz: 1ee9dca9c94e851293b68beeff95221453245095cc81c636e570bad128e3d6510cbf9c17d02093a5f214e8dad2ded951ee2e383f199f2bd84fe11935e6a371e4
6
+ metadata.gz: 9c699d8b18cf952003b5623dc070bff72a8104dbcea3742e4f8322c149c953a00be2006338aef9c664266b1e3aee94d1168535791077a0d02718e91f25e631a3
7
+ data.tar.gz: bed1c3540726189cc64ce303d26ff46671da086323e7e13cb942cdecd631ee4003e49fa582931ed3de647462743aa3ecee6ac2323b0076715dae0cc695d319f1
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.10
1
+ 0.7.11
@@ -7,7 +7,11 @@ module Anschel
7
7
  class Input
8
8
  class RabbitMQ < Base
9
9
  def initialize output, config, stats, log
10
- connection_defaults = {}
10
+ connection_defaults = {
11
+ heartbeat_interval: 30,
12
+ connection_timeout: 10,
13
+ automatically_recover: false
14
+ }
11
15
 
12
16
  exchange_defaults = {
13
17
  type: 'x-consistent-hash',
@@ -29,11 +33,14 @@ module Anschel
29
33
  connection = ::MarchHare.connect \
30
34
  connection_defaults.merge(config[:connection] || {})
31
35
 
36
+ handle_errors connection, log
37
+
32
38
  exchange_name = config[:exchange].delete(:name)
33
39
 
34
40
  @threads = config[:queues].map do |queue_name, queue_config|
35
41
  Thread.new do
36
42
  channel = connection.create_channel
43
+ channel.prefetch = config[:prefetch] || 256
37
44
 
38
45
  exchange = channel.exchange exchange_name, \
39
46
  exchange_defaults.merge(config[:exchange])
@@ -62,6 +69,47 @@ module Anschel
62
69
  @threads.map(&:kill)
63
70
  @stopped = true
64
71
  end
72
+
73
+ private
74
+
75
+ # Ensure broker errors results in logs and exits appropriately. Seems like
76
+ # the March Hare is catching exceptions under the hood, so we can't just
77
+ # raise within these callbacks, and we're stuck with this jankiness
78
+ def handle_errors connection, log
79
+ shutdown = false
80
+ blocked = false
81
+
82
+ connection.on_blocked { |reason| blocked = reason }
83
+
84
+ connection.on_unblocked { blocked = nil }
85
+
86
+ connection.on_shutdown { |_, reason| shutdown = reason }
87
+
88
+ Thread.new do
89
+ loop do
90
+ sleep 1
91
+
92
+ if shutdown
93
+ log.fatal \
94
+ event: 'input-rabbitmq-shutdown',
95
+ reason: shutdown
96
+ raise RuntimeError
97
+ end
98
+
99
+ if blocked
100
+ log.warn \
101
+ event: 'input-rabbitmq-blocked',
102
+ reason: blocked
103
+
104
+ elsif blocked.nil?
105
+ log.warn \
106
+ event: 'input-rabbitmq-unblocked'
107
+ end
108
+
109
+ blocked = false
110
+ end
111
+ end
112
+ end
65
113
  end
66
114
  end
67
115
  end
data/lib/anschel/main.rb CHANGED
@@ -85,8 +85,6 @@ module Anschel
85
85
  end
86
86
  end
87
87
 
88
- ts.each { |t| t.abort_on_exception = true }
89
-
90
88
  rescue Exception => e
91
89
  log.fatal \
92
90
  event: 'exception',
@@ -15,6 +15,7 @@ module Anschel
15
15
  File.open(path, 'w') do |f|
16
16
  loop do
17
17
  f.puts @queue.shift
18
+ f.flush
18
19
  end
19
20
  end
20
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anschel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.10
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sean Clemmer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2015-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -99,7 +99,7 @@ dependencies:
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '2.13'
102
+ version: '2.15'
103
103
  name: march_hare
104
104
  prerelease: false
105
105
  type: :runtime
@@ -107,7 +107,7 @@ dependencies:
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '2.13'
110
+ version: '2.15'
111
111
  - !ruby/object:Gem::Dependency
112
112
  requirement: !ruby/object:Gem::Requirement
113
113
  requirements: