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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92c4e95e3345fc0e7b14bbcc857e1eb068683aa71195f5c4ec12cb9c41cb502b
4
- data.tar.gz: f36375e9fa92be24efe78621aba3dfb055d0ef0c3ee9c786f6d9ce66d130e2c3
3
+ metadata.gz: ca9d3016280b5da1593899d13cc673628ebfaecd541c32ac111e9a0b33dc0694
4
+ data.tar.gz: d5c4c936574f79c726689f10a82f057691d20f26df50b46fdb5e799b6fca77bb
5
5
  SHA512:
6
- metadata.gz: 7ac5bee9428495e5db8850e8b62af15c85ec127724ce34abb6efaa00e4e33c319a3f8f6efc381b9e6f4b334479c9c76602eb2df48a3fb972795a10c7dbfe91d5
7
- data.tar.gz: 4faa60314422097b38cb53b4719c89f07ef0ceb18e223fa6ebfe4e1462d080a1f2c4db3379a085725af713a6b98c869a6efe2a77e86c78a60ccb443501ee6c9e
6
+ metadata.gz: 927b66235ed1b35777b79dcbd4581fdd17a56550074f2842939ba35be74d1069545398308df4a93e3be1ad6f056e4e4d46d607d041aab4a0092790df673d0e2f
7
+ data.tar.gz: 3f5493eff0fc05d825dcc17ab8ddc756e06cbabd2420be83ddbcdb3c84c1bc48d8b673328f88dd690ee5e996dbd1272a59d9251b449acfe1d40c6cd17a2d5e5c
@@ -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.3...HEAD)
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
 
@@ -8,7 +8,7 @@ module BunnyPublisher
8
8
 
9
9
  define_callbacks :after_publish, :before_publish, :around_publish
10
10
 
11
- attr_reader :connection, :channel, :exchange
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
- @channel = connection.create_channel
53
- @exchange = build_exchange
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, :republish_channel, :republish_exchange
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
- @republish_channel = republish_connection.create_channel
79
- @republish_exchange = clone_exchange_for_republish
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 clone_exchange_for_republish
87
- republish_channel.default_exchange if exchange.name == ''
99
+ def build_republish_exchange
100
+ return republish_channel.default_exchange if @exchange_name.nil? || @exchange_name == ''
88
101
 
89
- republish_channel.exchange exchange.name,
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BunnyPublisher
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
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.3
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-09-18 00:00:00.000000000 Z
11
+ date: 2020-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny