watership 0.3.1 → 0.3.2

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: b0b8d54b5999ef624829bbc4fe0ff41d4ba19294
4
- data.tar.gz: b59528de0c83ceca9e8a4e58fae7df5e08724ef0
3
+ metadata.gz: f34462d07d21cabc6ed72315b700aea62faba2c6
4
+ data.tar.gz: 690a5c5d300ac0568378184d442df18bc5c53a11
5
5
  SHA512:
6
- metadata.gz: 4e4976bd54777b0dbb6daa18fac5154d364756fadf0367cdd3756fdecabbc414d86b987b4a2da01274367bae0ec9f8ddae61b1d042f2a19f61898cdd5635a0b5
7
- data.tar.gz: d546eedabcf120b3d6f94d8e28ea9935d1aaf40483b94ac75715c7a7aca1d25fba11bfad5b2fdfe2ba12810bf40b75cd395ac0499aff3c876eb437906685ef4a
6
+ metadata.gz: c3ec9f80a2f1bd1b6462c8d2edc6e7ff4770f1b978b8ae1506ee6e124d5d86cb88cbfac1858174e6f7f408879d6d3cbbbb7c73b39e18b0563be3ca3399cc8eb5
7
+ data.tar.gz: 54e57a65d3ec490a72f04ac1a14ce841f35aa947fb817f64ae211715df46a6db9d000a717f40036615d5f43eff31079f2bd3c1cc0ebbaf98d6c3202c8451631f
@@ -2,15 +2,18 @@ require "json"
2
2
 
3
3
  module Watership
4
4
  class Consumer
5
- def initialize(consumer, url)
5
+ def initialize(consumer, url, channel_options = {}, queue_options = {})
6
6
  @consumer = consumer
7
7
  @url = url
8
+ @prefetch = channel_options.delete(:prefetch) || 0
9
+ @channel_opts = {durable: true}.merge(channel_options)
10
+ @queue_opts = {block: true, ack: true}.merge(queue_options)
8
11
  end
9
12
 
10
13
  def consume
11
14
  Thread.abort_on_exception = true
12
15
  begin
13
- queue.subscribe(block: true, ack: true) do |delivery_info, properties, payload|
16
+ queue.subscribe(@queue_opts) do |delivery_info, properties, payload|
14
17
  success = false
15
18
  begin
16
19
  @consumer.call(JSON.parse(payload))
@@ -45,7 +48,7 @@ module Watership
45
48
  private
46
49
 
47
50
  def queue
48
- @queue ||= channel.queue(@consumer.class::QUEUE, durable: true)
51
+ @queue ||= channel.queue(@consumer.class::QUEUE, @channel_options)
49
52
  end
50
53
 
51
54
  def connection
@@ -53,7 +56,11 @@ module Watership
53
56
  end
54
57
 
55
58
  def channel
56
- @connection ||= connection.create_channel
59
+ @channel ||= begin
60
+ c = connection.create_channel
61
+ c.prefetch(@prefetch)
62
+ c
63
+ end
57
64
  end
58
65
  end
59
66
  end
@@ -1,3 +1,3 @@
1
1
  module Watership
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: watership
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Scofield
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-15 00:00:00.000000000 Z
11
+ date: 2014-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler