watership 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/watership/consumer.rb +14 -6
- data/lib/watership/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7297b8a86504f62a6feb98b9ac8e19cdb75a3ed
|
4
|
+
data.tar.gz: 7b1d6e124680d147984f74d95ba19ae214b1d0a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9020adfcab698655ba127462d402a55b272ae6b1e8526325d956402286dc4feb3891dfb8eed2b4659f85ebd94049b6408f22275efe0f5a82e231ec121f315929
|
7
|
+
data.tar.gz: 292aa5b5b7d0d8a3af1a1acadba27549c034c35048b4d035eba8f5945991127c11966b51e2b50d9e962285e0c526944d595d8f07a17f0aba0698215b9287d3d8
|
data/lib/watership/consumer.rb
CHANGED
@@ -9,12 +9,12 @@ module Watership
|
|
9
9
|
@url = url
|
10
10
|
@prefetch = channel_options.delete(:prefetch) || Integer(ENV.fetch("RABBIT_CONSUMER_PREFETCH", 200))
|
11
11
|
@channel_opts = {durable: true}.merge(channel_options)
|
12
|
-
@queue_opts = {block:
|
12
|
+
@queue_opts = {block: false, ack: true}.merge(queue_options)
|
13
13
|
end
|
14
14
|
|
15
|
-
def consume
|
15
|
+
def consume(concurrency = 1)
|
16
16
|
Thread.abort_on_exception = true
|
17
|
-
|
17
|
+
concurrency.times do
|
18
18
|
queue.subscribe(@queue_opts) do |delivery_info, properties, payload|
|
19
19
|
success = true
|
20
20
|
data = JSON.parse(payload)
|
@@ -45,10 +45,18 @@ module Watership
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
48
|
-
ensure
|
49
|
-
logger.info "Closing Channel"
|
50
|
-
channel.close
|
51
48
|
end
|
49
|
+
|
50
|
+
# sleep forever
|
51
|
+
sleeping_thread = Thread.new { sleep }
|
52
|
+
Signal.trap("TERM") do
|
53
|
+
sleeping_thread.terminate
|
54
|
+
end
|
55
|
+
sleeping_thread.join
|
56
|
+
rescue Interrupt
|
57
|
+
ensure
|
58
|
+
logger.info "Closing Channel"
|
59
|
+
channel.close
|
52
60
|
end
|
53
61
|
|
54
62
|
private
|
data/lib/watership/version.rb
CHANGED