banter 1.1.1 → 1.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f2b3a73cf906e381fe1ca04744d8417ec0ba26b
|
4
|
+
data.tar.gz: ef17591c856e22066c3731f5887b22b7a641ca39
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0604404fa2508ca708f28e3e3fdb8dd9668820f1eb12a32bf6cd6e079c40028cc024347bd0076a88539a05157f34e5885b91b619a7f5d44dcc5e4e6a3cc47f7a
|
7
|
+
data.tar.gz: b6999995acd10379efaa21f3209053c2f44a5899653f6bb3c86720604ee0dc1415fed85488af3d9b0f38796223caf6ff6ef859bd7629aada42d683318fb6af37
|
@@ -10,13 +10,12 @@ module Banter
|
|
10
10
|
|
11
11
|
attr_reader :worker_class
|
12
12
|
|
13
|
-
def initialize(worker_class, request_key, queue_name, durable = true, topic = nil)
|
13
|
+
def initialize(worker_class, request_key, queue_name, durable = true, pool_size = 100, topic = nil)
|
14
14
|
@topic = topic || Banter::Configuration.topic_prefix
|
15
15
|
@request_key = request_key
|
16
16
|
@worker_class = worker_class
|
17
|
-
@durable = durable
|
18
17
|
@queue_name = queue_name
|
19
|
-
@subscriber = ::Banter::Server::RabbitMQSubscriber.new(@request_key, @queue_name, worker_class.queue_ttl,
|
18
|
+
@subscriber = ::Banter::Server::RabbitMQSubscriber.new(@request_key, @queue_name, worker_class.queue_ttl, durable, pool_size, @topic)
|
20
19
|
end
|
21
20
|
|
22
21
|
def start
|
@@ -7,11 +7,12 @@ module Banter
|
|
7
7
|
attr_reader :channel
|
8
8
|
attr_reader :ttl
|
9
9
|
|
10
|
-
def initialize(routing_key, queue_name, ttl, durable = true, topic = Banter::Configuration.topic_prefix)
|
10
|
+
def initialize(routing_key, queue_name, ttl, durable = true, pool_size = 100, topic = Banter::Configuration.topic_prefix)
|
11
11
|
@initial_key = routing_key
|
12
12
|
@durable = durable
|
13
13
|
@topic = topic
|
14
14
|
@ttl = ttl
|
15
|
+
@pool_size = pool_size
|
15
16
|
|
16
17
|
if @initial_key.present?
|
17
18
|
@routing_key = "#{@topic}.#{@initial_key}.#"
|
@@ -40,18 +41,9 @@ module Banter
|
|
40
41
|
queue_arguments["x-dead-letter-exchange"] = Configuration.dead_letter_queue if Configuration.dead_letter_queue.present?
|
41
42
|
queue_arguments["x-message-ttl"] = ttl * 1000
|
42
43
|
|
43
|
-
|
44
|
-
# Something is wrong with basic_qos because the server cannot be quickly bounced when this happens, and for messages to be
|
45
|
-
# quickly picked up. It seems sporadic. It could be a timing thing but I am unsure.
|
46
|
-
# Only grab 1 message at a time, otherwise, we will have to write some extra conditions to reject
|
47
|
-
# all the other messages that they already pulled down, which then could make the subscriber
|
48
|
-
# run out of memory, etc
|
49
|
-
# @channel.basic_qos(1)
|
44
|
+
@channel.basic_qos(@pool_size)
|
50
45
|
|
51
|
-
# Need to mark the queue as durable
|
52
46
|
rabbit_queue = @channel.queue(@queue_name, durable: @durable, exclusive: false, arguments: queue_arguments)
|
53
|
-
# rabbit_queue = @channel.queue(@queue_name, arguments: queue_arguments)
|
54
|
-
|
55
47
|
@listener = rabbit_queue.bind(@exchange, routing_key: @routing_key, exclusive: false)
|
56
48
|
|
57
49
|
# Parameters for subscribe that might be useful:
|
@@ -99,9 +99,10 @@ module Banter
|
|
99
99
|
routing_key = subscriber.subscribed_key
|
100
100
|
durable = subscriber.durable
|
101
101
|
queue_name = subscriber.generated_queue_name(routing_key, application_name)
|
102
|
+
pool_size = Banter::Configuration.configuration[:pool_size] || 100
|
102
103
|
|
103
|
-
STDOUT.puts "Setting up listener for request_key: #{routing_key} and queue:#{application_name}"
|
104
|
-
ClientQueueListener.new(subscriber, routing_key, queue_name, durable)
|
104
|
+
STDOUT.puts "Setting up listener for request_key: #{routing_key} and queue:#{application_name} with qos setting: #{pool_size}"
|
105
|
+
ClientQueueListener.new(subscriber, routing_key, queue_name, durable, pool_size)
|
105
106
|
end
|
106
107
|
end
|
107
108
|
end
|
data/lib/banter/version.rb
CHANGED
@@ -8,15 +8,32 @@ describe Banter::Server::SubscriberServer do
|
|
8
8
|
let!(:application_name) { "testsubscriber" }
|
9
9
|
let!(:durable) { true }
|
10
10
|
describe '#set_workers' do
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
context "default config" do
|
12
|
+
before {
|
13
|
+
Banter::Configuration.application_name = application_name
|
14
|
+
allow(Banter::Server::ClientQueueListener).to receive(:new)
|
15
|
+
subject.set_workers([MyTestSubscriber1, MyTestSubscriber2])
|
16
|
+
}
|
17
|
+
|
18
|
+
it "creates queue listeners" do
|
19
|
+
expect(Banter::Server::ClientQueueListener).to have_received(:new).with(MyTestSubscriber1, "foo.bar.one", "foo.bar.one_#{application_name}", durable, 100)
|
20
|
+
expect(Banter::Server::ClientQueueListener).to have_received(:new).with(MyTestSubscriber2, "foo.bar.two", "foo.bar.two_#{application_name}", durable, 100)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "set pool_size" do
|
25
|
+
before {
|
26
|
+
Banter::Configuration.application_name = application_name
|
27
|
+
allow(Banter::Server::ClientQueueListener).to receive(:new)
|
28
|
+
Banter::Configuration.configuration[:pool_size] = 200
|
29
|
+
subject.set_workers([MyTestSubscriber1, MyTestSubscriber2])
|
30
|
+
}
|
31
|
+
|
32
|
+
it "creates queue listeners" do
|
33
|
+
expect(Banter::Server::ClientQueueListener).to have_received(:new).with(MyTestSubscriber1, "foo.bar.one", "foo.bar.one_#{application_name}", durable, 200)
|
34
|
+
expect(Banter::Server::ClientQueueListener).to have_received(:new).with(MyTestSubscriber2, "foo.bar.two", "foo.bar.two_#{application_name}", durable, 200)
|
35
|
+
end
|
36
|
+
|
20
37
|
end
|
21
38
|
end
|
22
39
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: banter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- The Honest Company
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-09-
|
14
|
+
date: 2014-09-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|