bunny-publisher 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -1
- data/lib/bunny_publisher/base.rb +20 -3
- data/lib/bunny_publisher/mandatory.rb +19 -7
- data/lib/bunny_publisher/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca9d3016280b5da1593899d13cc673628ebfaecd541c32ac111e9a0b33dc0694
|
4
|
+
data.tar.gz: d5c4c936574f79c726689f10a82f057691d20f26df50b46fdb5e799b6fca77bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 927b66235ed1b35777b79dcbd4581fdd17a56550074f2842939ba35be74d1069545398308df4a93e3be1ad6f056e4e4d46d607d041aab4a0092790df673d0e2f
|
7
|
+
data.tar.gz: 3f5493eff0fc05d825dcc17ab8ddc756e06cbabd2420be83ddbcdb3c84c1bc48d8b673328f88dd690ee5e996dbd1272a59d9251b449acfe1d40c6cd17a2d5e5c
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,17 @@ All notable changes to this project will be documented in this file.
|
|
4
4
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
6
6
|
|
7
|
-
## [Unreleased](https://github.com/veeqo/bunny-publisher/compare/v0.1.
|
7
|
+
## [Unreleased](https://github.com/veeqo/bunny-publisher/compare/v0.1.4...HEAD)
|
8
|
+
|
9
|
+
|
10
|
+
## [0.1.4](https://github.com/veeqo/bunny-publisher/compare/v0.1.3...v0.1.4) - 2020-11-03
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- [#5](https://github.com/veeqo/bunny-publisher/pull/5) Test against ruby 2.7.2
|
14
|
+
|
15
|
+
### Fixed
|
16
|
+
- [#6](https://github.com/veeqo/bunny-publisher/pull/6) Do not share channels between threads
|
17
|
+
|
8
18
|
|
9
19
|
## [0.1.3](https://github.com/veeqo/bunny-publisher/compare/v0.1.2...v0.1.3) - 2020-09-18
|
10
20
|
|
data/lib/bunny_publisher/base.rb
CHANGED
@@ -8,7 +8,7 @@ module BunnyPublisher
|
|
8
8
|
|
9
9
|
define_callbacks :after_publish, :before_publish, :around_publish
|
10
10
|
|
11
|
-
attr_reader :connection
|
11
|
+
attr_reader :connection
|
12
12
|
|
13
13
|
def initialize(publish_connection: nil, connection: nil, exchange: nil, exchange_options: {}, **options)
|
14
14
|
@mutex = Mutex.new
|
@@ -49,8 +49,25 @@ module BunnyPublisher
|
|
49
49
|
def connect!
|
50
50
|
@connection ||= build_connection
|
51
51
|
connection.start
|
52
|
-
|
53
|
-
|
52
|
+
|
53
|
+
connection_variables[:channel] ||= connection.create_channel
|
54
|
+
connection_variables[:exchange] ||= build_exchange
|
55
|
+
end
|
56
|
+
|
57
|
+
def thread_variables
|
58
|
+
Thread.current[:bunny_publisher] ||= {}.compare_by_identity
|
59
|
+
end
|
60
|
+
|
61
|
+
def connection_variables
|
62
|
+
thread_variables[connection] ||= {}
|
63
|
+
end
|
64
|
+
|
65
|
+
def channel
|
66
|
+
connection_variables[:channel]
|
67
|
+
end
|
68
|
+
|
69
|
+
def exchange
|
70
|
+
connection_variables[:exchange]
|
54
71
|
end
|
55
72
|
|
56
73
|
def build_connection
|
@@ -49,7 +49,7 @@ module BunnyPublisher
|
|
49
49
|
|
50
50
|
private
|
51
51
|
|
52
|
-
attr_reader :republish_connection
|
52
|
+
attr_reader :republish_connection
|
53
53
|
|
54
54
|
def connect!
|
55
55
|
super
|
@@ -75,19 +75,31 @@ module BunnyPublisher
|
|
75
75
|
def connect_for_republish!
|
76
76
|
@republish_connection ||= build_republish_connection
|
77
77
|
republish_connection.start
|
78
|
-
|
79
|
-
|
78
|
+
|
79
|
+
republish_connection_variables[:republish_channel] ||= republish_connection.create_channel
|
80
|
+
republish_connection_variables[:republish_exchange] ||= build_republish_exchange
|
81
|
+
end
|
82
|
+
|
83
|
+
def republish_connection_variables
|
84
|
+
thread_variables[republish_connection] ||= {}
|
85
|
+
end
|
86
|
+
|
87
|
+
def republish_channel
|
88
|
+
republish_connection_variables[:republish_channel]
|
89
|
+
end
|
90
|
+
|
91
|
+
def republish_exchange
|
92
|
+
republish_connection_variables[:republish_exchange]
|
80
93
|
end
|
81
94
|
|
82
95
|
def build_republish_connection
|
83
96
|
Bunny.new(connection.instance_variable_get(:'@opts')) # TODO: find more elegant way to "clone" connection
|
84
97
|
end
|
85
98
|
|
86
|
-
def
|
87
|
-
republish_channel.default_exchange if
|
99
|
+
def build_republish_exchange
|
100
|
+
return republish_channel.default_exchange if @exchange_name.nil? || @exchange_name == ''
|
88
101
|
|
89
|
-
republish_channel.exchange
|
90
|
-
exchange.instance_variable_get(:'@options').merge(type: exchange.type)
|
102
|
+
republish_channel.exchange(@exchange_name, @exchange_options)
|
91
103
|
end
|
92
104
|
|
93
105
|
def on_message_return(return_info, properties, message)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bunny-publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rustam Sharshenov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|