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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c343b8f27c9dfabdbef3863bda8a918eeaf0097a
4
- data.tar.gz: 977ef5d709616c80d9c3ca07a5d05dbd0f378570
3
+ metadata.gz: c7297b8a86504f62a6feb98b9ac8e19cdb75a3ed
4
+ data.tar.gz: 7b1d6e124680d147984f74d95ba19ae214b1d0a5
5
5
  SHA512:
6
- metadata.gz: 99cc83e6ad322b28593c8ff9193343dc0f1c80a45e9a43219eeeafeb324ccde6d6057fc20edcc56c134e37716000227d60d3df045badff6d6e1fab718044c140
7
- data.tar.gz: d763b661e3ecaa1df2bd646ae240d6eddc7a9ce865375996e7c9eef303e78afb07704460365ba448b3ac3b07050c680378fff72393e326918349ea4d4144386f
6
+ metadata.gz: 9020adfcab698655ba127462d402a55b272ae6b1e8526325d956402286dc4feb3891dfb8eed2b4659f85ebd94049b6408f22275efe0f5a82e231ec121f315929
7
+ data.tar.gz: 292aa5b5b7d0d8a3af1a1acadba27549c034c35048b4d035eba8f5945991127c11966b51e2b50d9e962285e0c526944d595d8f07a17f0aba0698215b9287d3d8
@@ -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: true, ack: true}.merge(queue_options)
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
- begin
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
@@ -1,3 +1,3 @@
1
1
  module Watership
2
- VERSION = '0.4.0'
2
+ VERSION = '0.5.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watership
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Scofield