bug_bunny 4.11.1 → 4.13.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 +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +34 -1
- data/lib/bug_bunny/client.rb +80 -33
- data/lib/bug_bunny/configuration.rb +39 -2
- data/lib/bug_bunny/exception.rb +31 -0
- data/lib/bug_bunny/producer.rb +109 -14
- data/lib/bug_bunny/request.rb +18 -2
- data/lib/bug_bunny/session.rb +50 -1
- data/lib/bug_bunny/version.rb +1 -1
- data/skill/SKILL.md +29 -2
- data/skill/references/client-middleware.md +91 -7
- data/skill/references/errores.md +7 -0
- data/skills.yml +8 -23
- data/spec/support/bunny_mocks.rb +36 -0
- data/spec/unit/client_session_pool_spec.rb +79 -2
- data/spec/unit/configuration_spec.rb +25 -0
- data/spec/unit/producer_spec.rb +142 -0
- data/spec/unit/request_spec.rb +29 -0
- data/spec/unit/session_spec.rb +82 -0
- metadata +3 -4
- data/skills.lock +0 -33
data/spec/unit/session_spec.rb
CHANGED
|
@@ -69,6 +69,88 @@ RSpec.describe BugBunny::Session do
|
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
describe '#on_return handler' do
|
|
73
|
+
let(:return_info) do
|
|
74
|
+
Struct.new(:reply_code, :reply_text, :exchange, :routing_key)
|
|
75
|
+
.new(312, 'NO_ROUTE', 'evt_x', 'unbound.key')
|
|
76
|
+
end
|
|
77
|
+
let(:properties) { double('properties') }
|
|
78
|
+
let(:body) { '{"a":1}' }
|
|
79
|
+
|
|
80
|
+
before do
|
|
81
|
+
# Logger en memoria para inspeccionar el default
|
|
82
|
+
@log_io = StringIO.new
|
|
83
|
+
BugBunny.configuration.logger = Logger.new(@log_io)
|
|
84
|
+
BugBunny.configuration.on_return = nil
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
after do
|
|
88
|
+
BugBunny.configuration.logger = Logger.new($stdout).tap { |l| l.level = Logger::INFO }
|
|
89
|
+
BugBunny.configuration.on_return = nil
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'se registra sobre el exchange cuando publisher_confirms está activo' do
|
|
93
|
+
exchange = session.exchange(name: 'evt_x', type: 'topic')
|
|
94
|
+
|
|
95
|
+
expect { exchange.fire_return(return_info, properties, body) }.not_to raise_error
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it 'registra una sola vez por nombre de exchange' do
|
|
99
|
+
first = session.exchange(name: 'evt_x', type: 'topic')
|
|
100
|
+
second = session.exchange(name: 'evt_x', type: 'topic')
|
|
101
|
+
|
|
102
|
+
expect(second).to be(first)
|
|
103
|
+
expect(session.instance_variable_get(:@configured_returns)).to include('evt_x' => true)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
it 'NO se registra cuando publisher_confirms está desactivado' do
|
|
107
|
+
fresh_channel = BunnyMocks::FakeChannel.new(true)
|
|
108
|
+
fresh_conn = BunnyMocks::FakeConnection.new(true, fresh_channel)
|
|
109
|
+
no_confirms = described_class.new(fresh_conn, publisher_confirms: false)
|
|
110
|
+
exchange = no_confirms.exchange(name: 'evt_x', type: 'topic')
|
|
111
|
+
|
|
112
|
+
expect(exchange.instance_variable_get(:@on_return_handler)).to be_nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
it 'NO se registra sobre el default exchange (name vacío)' do
|
|
116
|
+
default = session.exchange # name nil → default_exchange
|
|
117
|
+
|
|
118
|
+
expect(default.instance_variable_get(:@on_return_handler)).to be_nil
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
it 'invoca el callback de Configuration#on_return cuando está definido' do
|
|
122
|
+
received = nil
|
|
123
|
+
BugBunny.configuration.on_return = lambda { |ri, props, b|
|
|
124
|
+
received = { rk: ri.routing_key, props: props, body: b }
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
exchange = session.exchange(name: 'evt_x', type: 'topic')
|
|
128
|
+
exchange.fire_return(return_info, properties, body)
|
|
129
|
+
|
|
130
|
+
expect(received).to include(rk: 'unbound.key', body: '{"a":1}')
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it 'logea session.broker_return como :warn cuando no hay callback' do
|
|
134
|
+
exchange = session.exchange(name: 'evt_x', type: 'topic')
|
|
135
|
+
exchange.fire_return(return_info, properties, body)
|
|
136
|
+
|
|
137
|
+
log = @log_io.string
|
|
138
|
+
expect(log).to include('event=session.broker_return')
|
|
139
|
+
expect(log).to include('reply_code=312')
|
|
140
|
+
expect(log).to include('routing_key=unbound.key')
|
|
141
|
+
expect(log).to include('body_size=7')
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
it 'no propaga excepciones del callback de usuario' do
|
|
145
|
+
BugBunny.configuration.on_return = ->(_, _, _) { raise 'boom' }
|
|
146
|
+
|
|
147
|
+
exchange = session.exchange(name: 'evt_x', type: 'topic')
|
|
148
|
+
|
|
149
|
+
expect { exchange.fire_return(return_info, properties, body) }.not_to raise_error
|
|
150
|
+
expect(@log_io.string).to include('event=session.on_return_failed')
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
72
154
|
describe '#close' do
|
|
73
155
|
it 'cierra el canal y lo nilifica' do
|
|
74
156
|
session.channel
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bug_bunny
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- gabix
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-05-11 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bunny
|
|
@@ -269,7 +269,6 @@ files:
|
|
|
269
269
|
- skill/references/routing.md
|
|
270
270
|
- skill/references/testing.md
|
|
271
271
|
- skills-lock.json
|
|
272
|
-
- skills.lock
|
|
273
272
|
- skills.yml
|
|
274
273
|
- spec/integration/client_spec.rb
|
|
275
274
|
- spec/integration/consumer_middleware_spec.rb
|
|
@@ -304,7 +303,7 @@ metadata:
|
|
|
304
303
|
homepage_uri: https://github.com/gedera/bug_bunny
|
|
305
304
|
source_code_uri: https://github.com/gedera/bug_bunny
|
|
306
305
|
changelog_uri: https://github.com/gedera/bug_bunny/blob/main/CHANGELOG.md
|
|
307
|
-
documentation_uri: https://github.com/gedera/bug_bunny/blob/v4.
|
|
306
|
+
documentation_uri: https://github.com/gedera/bug_bunny/blob/v4.13.0/skill
|
|
308
307
|
post_install_message:
|
|
309
308
|
rdoc_options: []
|
|
310
309
|
require_paths:
|
data/skills.lock
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
synced_at: '2026-04-08 09:13:30'
|
|
3
|
-
skills:
|
|
4
|
-
- name: agent-review
|
|
5
|
-
scope: local
|
|
6
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/agent-review"
|
|
7
|
-
- name: ai-reports
|
|
8
|
-
scope: local
|
|
9
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/ai-reports"
|
|
10
|
-
- name: documentation-writer
|
|
11
|
-
scope: local
|
|
12
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/documentation-writer"
|
|
13
|
-
- name: find-skills
|
|
14
|
-
scope: local
|
|
15
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/find-skills"
|
|
16
|
-
- name: gem-release
|
|
17
|
-
scope: local
|
|
18
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/gem-release"
|
|
19
|
-
- name: quality-code
|
|
20
|
-
scope: local
|
|
21
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/quality-code"
|
|
22
|
-
- name: rabbitmq-expert
|
|
23
|
-
scope: local
|
|
24
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/rabbitmq-expert"
|
|
25
|
-
- name: skill-builder
|
|
26
|
-
scope: local
|
|
27
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/skill-builder"
|
|
28
|
-
- name: skill-manager
|
|
29
|
-
scope: local
|
|
30
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/skill-manager"
|
|
31
|
-
- name: yard
|
|
32
|
-
scope: local
|
|
33
|
-
path: "/Users/gabriel/src/gems/bug_bunny/.agents/skills/yard"
|