harmoniser 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a7c3ac5b97ffe50dee2438808e152133893642092fee47a74e49f31e5440686
4
- data.tar.gz: 156dbce5e8ba12711085e55d2a2b6f823259946d0df42d6cccd7bd29aeba0139
3
+ metadata.gz: 1d5d92e016161196555365ed7937a455d1e4765c955afa173f59ebde8323a51d
4
+ data.tar.gz: 735e2b70476779ce10ab83ad2382d70b9ac95598dbdf7d251e90c18ffd025203
5
5
  SHA512:
6
- metadata.gz: 3c14b5e163b0d3863ae1e25db3dc7aaec5ac6debacfe6cb0148066b5154156619b3692a7ea1e72d03d27e407a6366ad93c879476e04e606f864522ba56ffec59
7
- data.tar.gz: 546204550ed925fac2e177240ec3266a25d61d81d9034019f76653588af7141c797be2ed42d576000cb7de72699843333b59cfafdb3d50a80a7a31a9596e1172
6
+ metadata.gz: b5e54c2077c6fe92dfb649e3ae6d1407b97db2ef8226cf7ef9baad6d700dd11bb24246388fe883de4eb0e24f989cafe7c88c7d8e4c645bb8f7a44edca0719d34
7
+ data.tar.gz: 77c5675b22841464d6381e9285b0e1485ab76f0178dd257ec0b8f8463d35b7e5f55a55ab3f9d5333a425bc4de4efac833810a9a2069bb729bb6bdc3b5fe65c89
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.15.0] - 2026-03-03
4
+
5
+ ### Changed
6
+ - Close all channels tracked by `Harmoniser::Connection` before closing the connection. This ensures consumers are cancelled and channels are closed while the connection is still open, preventing `Bunny::ConnectionClosedError` that could occur when a consumer acknowledges a message concurrently during shutdown
7
+ - Introduce `Harmoniser::Channel#close` and `Harmoniser::Channel#open?` to expose channel lifecycle as part of the public interface
8
+ - Inject logger into `Harmoniser::Channel` for consistent logger usage across the codebase
9
+
3
10
  ## [0.14.0] - 2025-11-25
4
11
 
5
12
  ### Added
@@ -6,16 +6,25 @@ module Harmoniser
6
6
 
7
7
  def_delegators :@bunny_channel,
8
8
  :exchange,
9
+ :open?,
9
10
  :queue,
10
11
  :queue_bind
11
12
 
12
13
  attr_reader :bunny_channel
13
14
 
14
- def initialize(bunny_channel)
15
+ def initialize(bunny_channel, logger: Harmoniser.logger)
15
16
  @bunny_channel = bunny_channel
17
+ @logger = logger
16
18
  after_initialize
17
19
  end
18
20
 
21
+ def close
22
+ @bunny_channel.close
23
+ rescue => e
24
+ @logger.warn("Failed to close channel: exception = `#{e.detailed_message}`")
25
+ false
26
+ end
27
+
19
28
  private
20
29
 
21
30
  def after_initialize
@@ -41,7 +50,7 @@ module Harmoniser
41
50
  end
42
51
 
43
52
  stringified_attributes = attributes.map { |k, v| "#{k} = `#{v}`" }.join(", ")
44
- Harmoniser.logger.warn("Default on_error handler executed for channel: #{stringified_attributes}")
53
+ @logger.warn("Default on_error handler executed for channel: #{stringified_attributes}")
45
54
  maybe_kill_process(amq_method)
46
55
  end
47
56
 
@@ -22,6 +22,7 @@ module Harmoniser
22
22
  connection
23
23
  .create_channel(nil, consumer_pool_size, false, consumer_pool_shutdown_timeout)
24
24
  .yield_self { |bunny_channel| Channel.new(bunny_channel) }
25
+ .tap { |channel| connection.register_channel(channel) }
25
26
  end
26
27
  end
27
28
 
@@ -25,11 +25,16 @@ module Harmoniser
25
25
  def initialize(opts, error_handler: ErrorHandler.default, logger: Harmoniser.logger)
26
26
  @error_handler = error_handler
27
27
  @logger = logger
28
+ @channels = []
28
29
  @bunny = Bunny.new(maybe_dynamic_opts(opts)).tap do |bunny|
29
30
  attach_callbacks(bunny)
30
31
  end
31
32
  end
32
33
 
34
+ def register_channel(channel)
35
+ @channels << channel
36
+ end
37
+
33
38
  def to_s
34
39
  "<#{self.class.name}>:#{object_id} #{user}@#{host}:#{port}, connection_name = `#{connection_name}`, vhost = `#{vhost}`"
35
40
  end
@@ -54,6 +59,7 @@ module Harmoniser
54
59
 
55
60
  def close
56
61
  @logger.info("Connection will be closed: connection = `#{self}`")
62
+ close_channels
57
63
  @bunny.close.tap do
58
64
  @logger.info("Connection closed: connection = `#{self}`")
59
65
  end
@@ -64,6 +70,10 @@ module Harmoniser
64
70
 
65
71
  private
66
72
 
73
+ def close_channels
74
+ @channels.each { |channel| channel.close if channel.open? }
75
+ end
76
+
67
77
  def attach_callbacks(bunny)
68
78
  bunny.on_blocked do |blocked|
69
79
  @logger.warn("Connection blocked: connection = `#{self}`, reason = `#{blocked.reason}`")
@@ -1,3 +1,3 @@
1
1
  module Harmoniser
2
- VERSION = "0.14.0"
2
+ VERSION = "0.15.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: harmoniser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jose Lloret
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-25 00:00:00.000000000 Z
11
+ date: 2026-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny