bunny-publisher 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/lib/bunny_publisher/base.rb +18 -10
- data/lib/bunny_publisher/mandatory.rb +10 -11
- data/lib/bunny_publisher/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 114f01661b4bf20f7b8e3e0c2a09dba2b969cac13f5b9e1140edd0a8048b8f86
|
4
|
+
data.tar.gz: e3a18568ee95e4eca7d5093b9ed3326cffe71c1890c235903d9f4de6395b6efd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 528c55964119b778c6d7573a489a76b0c315002ccdfff3770a34d26439f76e050e8a629012fe76739cefaffad667201ba1a24b9fa409401fb50b07eb4e6972cd
|
7
|
+
data.tar.gz: 933da9ba2d644c5138b4b091dede2935de7bab125cadd7007d1b4a7c311717ceb94bc417fe5251d77f7f11dbe7c757a2c45201d369044cb8b5fe14db6eea2a7e
|
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,13 @@ 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.6...HEAD)
|
8
|
+
|
9
|
+
|
10
|
+
## [0.1.6](https://github.com/veeqo/bunny-publisher/compare/v0.1.5...v0.1.6) - 2020-11-24
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- [#8](https://github.com/veeqo/bunny-publisher/pull/8) Fix errors on recovery from connection failures
|
8
14
|
|
9
15
|
|
10
16
|
## [0.1.5](https://github.com/veeqo/bunny-publisher/compare/v0.1.4...v0.1.5) - 2020-11-04
|
data/lib/bunny_publisher/base.rb
CHANGED
@@ -45,14 +45,26 @@ module BunnyPublisher
|
|
45
45
|
private
|
46
46
|
|
47
47
|
def ensure_connection!
|
48
|
-
|
48
|
+
@connection ||= build_connection
|
49
|
+
|
50
|
+
connection.start if connection.status == :not_connected # Lazy connection initialization.
|
51
|
+
|
52
|
+
wait_until_connection_ready(connection)
|
53
|
+
|
54
|
+
@channel ||= connection.create_channel
|
55
|
+
@exchange ||= build_exchange
|
49
56
|
end
|
50
57
|
|
51
|
-
def
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
def wait_until_connection_ready(conn)
|
59
|
+
Timeout.timeout((conn.heartbeat || 60) * 2) do # 60 seconds is a default Bunny heartbeat
|
60
|
+
loop do
|
61
|
+
return if conn.status == :open && conn.transport.open?
|
62
|
+
|
63
|
+
sleep 0.001
|
64
|
+
end
|
65
|
+
end
|
66
|
+
rescue Timeout::Error
|
67
|
+
# Connection recovery takes too long, let the next interaction fail with error then.
|
56
68
|
end
|
57
69
|
|
58
70
|
def build_connection
|
@@ -64,9 +76,5 @@ module BunnyPublisher
|
|
64
76
|
|
65
77
|
channel.exchange(@exchange_name, @exchange_options)
|
66
78
|
end
|
67
|
-
|
68
|
-
def connected?
|
69
|
-
@connection&.connected? && channel
|
70
|
-
end
|
71
79
|
end
|
72
80
|
end
|
@@ -51,9 +51,11 @@ module BunnyPublisher
|
|
51
51
|
|
52
52
|
attr_reader :republish_connection, :republish_channel, :republish_exchange
|
53
53
|
|
54
|
-
def
|
54
|
+
def ensure_connection!
|
55
55
|
super
|
56
56
|
|
57
|
+
return if @on_return_set
|
58
|
+
|
57
59
|
# `on_return` is called within a frameset of amqp connection.
|
58
60
|
# Any interaction within the same connection leads to error. This is why we need extra connection.
|
59
61
|
# https://github.com/ruby-amqp/bunny/blob/7fb05abf36637557f75a69790be78f9cc1cea807/lib/bunny/session.rb#L683
|
@@ -62,21 +64,18 @@ module BunnyPublisher
|
|
62
64
|
else
|
63
65
|
exchange.on_return { |*attrs| on_message_return(*attrs) }
|
64
66
|
end
|
67
|
+
|
68
|
+
@on_return_set = true
|
65
69
|
end
|
66
70
|
|
67
71
|
def ensure_republish_connection!
|
68
|
-
|
69
|
-
|
72
|
+
@republish_connection ||= build_republish_connection
|
73
|
+
republish_connection.start if republish_connection.status == :not_connected # Lazy connection initialization.
|
70
74
|
|
71
|
-
|
72
|
-
republish_connection&.connected? && republish_channel
|
73
|
-
end
|
75
|
+
wait_until_connection_ready(republish_connection)
|
74
76
|
|
75
|
-
|
76
|
-
@
|
77
|
-
republish_connection.start
|
78
|
-
@republish_channel = republish_connection.create_channel
|
79
|
-
@republish_exchange = clone_exchange_for_republish
|
77
|
+
@republish_channel ||= republish_connection.create_channel
|
78
|
+
@republish_exchange ||= clone_exchange_for_republish
|
80
79
|
end
|
81
80
|
|
82
81
|
def build_republish_connection
|
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.6
|
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-
|
11
|
+
date: 2020-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -134,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
134
|
- !ruby/object:Gem::Version
|
135
135
|
version: '0'
|
136
136
|
requirements: []
|
137
|
-
rubygems_version: 3.
|
137
|
+
rubygems_version: 3.1.4
|
138
138
|
signing_key:
|
139
139
|
specification_version: 4
|
140
140
|
summary: AMQP publisher for RabbitMQ based on Bunny
|