basquiat 1.3.6 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -0
- data/basquiat.gemspec +1 -0
- data/lib/basquiat.rb +1 -0
- data/lib/basquiat/adapters/rabbitmq/configuration.rb +1 -1
- data/lib/basquiat/adapters/rabbitmq_adapter.rb +14 -4
- data/lib/basquiat/version.rb +1 -1
- data/spec/lib/adapters/rabbitmq_adapter_spec.rb +26 -4
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c58b903c923eb880488c658ccd185076edac51ccc279cdc3e03833676a6a1770
|
4
|
+
data.tar.gz: c68e49c4012d1d52b199d22df0ce6a04cfd9f551361e516e927f8679d0cc9719
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99dee9a41070083aa8cc9c8f1dd762444684246c4592e97ea6b26b2eee35be88cb200d5704e1771bb076be0f1cce6a58b3796f99675d589ea3d47baf0167d102
|
7
|
+
data.tar.gz: 5299eba89ddd38bbaeb081aa8bae8ddeede2614b95745c42a68c5e71a8aaaa974406b2e5fb33b212a54fe06e820e1b9cfa897f3495a9127747f5c18fd28d0a4e
|
data/README.md
CHANGED
data/basquiat.gemspec
CHANGED
data/lib/basquiat.rb
CHANGED
@@ -22,7 +22,7 @@ module Basquiat
|
|
22
22
|
durable: true,
|
23
23
|
options: {}
|
24
24
|
},
|
25
|
-
publisher: { confirm: true, persistent: false },
|
25
|
+
publisher: { confirm: true, persistent: false, session_pool: { size: 1, timeout: 5 } },
|
26
26
|
consumer: { prefetch: 1000, manual_ack: true },
|
27
27
|
requeue: { enabled: false } }
|
28
28
|
end
|
@@ -43,7 +43,7 @@ module Basquiat
|
|
43
43
|
# @param message [Hash] the message to be publish
|
44
44
|
# @param props [Hash] other properties you wish to publish with the message, such as custom headers etc.
|
45
45
|
def publish(event, message, props: {})
|
46
|
-
session.publish(event, message, props)
|
46
|
+
session_pool.with { |session| session.publish(event, message, props) }
|
47
47
|
disconnect unless options[:publisher][:persistent]
|
48
48
|
end
|
49
49
|
|
@@ -67,9 +67,10 @@ module Basquiat
|
|
67
67
|
# Reset the connection to RabbitMQ.
|
68
68
|
def reset_connection
|
69
69
|
connection.disconnect
|
70
|
-
@connection
|
71
|
-
@session
|
72
|
-
@
|
70
|
+
@connection = nil
|
71
|
+
@session = nil
|
72
|
+
@session_pool = nil
|
73
|
+
@strategy = nil
|
73
74
|
end
|
74
75
|
|
75
76
|
alias disconnect reset_connection
|
@@ -86,6 +87,15 @@ module Basquiat
|
|
86
87
|
@session ||= Session.new(connection.create_channel, @configuration.session_options)
|
87
88
|
end
|
88
89
|
|
90
|
+
# Lazy initializes and return the session pool
|
91
|
+
# @return [ConnectionPool<Session>]
|
92
|
+
def session_pool
|
93
|
+
@session_pool ||= ConnectionPool.new(size: options[:publisher][:session_pool][:size],
|
94
|
+
timeout: options[:publisher][:session_pool][:timeout]) do
|
95
|
+
Session.new(connection.create_channel, @configuration.session_options)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
89
99
|
private
|
90
100
|
|
91
101
|
# Lazy initializes the connection
|
data/lib/basquiat/version.rb
CHANGED
@@ -22,10 +22,32 @@ RSpec.describe Basquiat::Adapters::RabbitMq do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
context 'publisher' do
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
context 'main process' do
|
26
|
+
it '#publish [enqueue a message]' do
|
27
|
+
expect do
|
28
|
+
adapter.publish('messages.welcome', data: 'A Nice Welcome Message')
|
29
|
+
end.to_not raise_error
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'multiple threads' do
|
34
|
+
let(:base_options) do
|
35
|
+
{ connection: { hosts: [ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_ADDR') { 'localhost' }],
|
36
|
+
port: ENV.fetch('BASQUIAT_RABBITMQ_1_PORT_5672_TCP_PORT') { 5672 } },
|
37
|
+
publisher: { persistent: true, session_pool: { size: 10 } } }
|
38
|
+
end
|
39
|
+
|
40
|
+
it '#publish [enqueue a message 10 times concurrently]' do
|
41
|
+
expect do
|
42
|
+
threads = []
|
43
|
+
|
44
|
+
10.times do
|
45
|
+
threads << Thread.new { adapter.publish('messages.welcome', data: 'A Nice Welcome Message') }
|
46
|
+
end
|
47
|
+
|
48
|
+
threads.each(&:join)
|
49
|
+
end.not_to raise_error
|
50
|
+
end
|
29
51
|
end
|
30
52
|
end
|
31
53
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: basquiat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcello "mereghost" Rocha
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-06
|
12
|
+
date: 2018-07-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -221,6 +221,20 @@ dependencies:
|
|
221
221
|
- - ">="
|
222
222
|
- !ruby/object:Gem::Version
|
223
223
|
version: '0'
|
224
|
+
- !ruby/object:Gem::Dependency
|
225
|
+
name: connection_pool
|
226
|
+
requirement: !ruby/object:Gem::Requirement
|
227
|
+
requirements:
|
228
|
+
- - ">="
|
229
|
+
- !ruby/object:Gem::Version
|
230
|
+
version: '0'
|
231
|
+
type: :runtime
|
232
|
+
prerelease: false
|
233
|
+
version_requirements: !ruby/object:Gem::Requirement
|
234
|
+
requirements:
|
235
|
+
- - ">="
|
236
|
+
- !ruby/object:Gem::Version
|
237
|
+
version: '0'
|
224
238
|
- !ruby/object:Gem::Dependency
|
225
239
|
name: multi_json
|
226
240
|
requirement: !ruby/object:Gem::Requirement
|