bug_bunny 0.2.2 → 0.2.4
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/lib/bug_bunny/adapter.rb +11 -48
- data/lib/bug_bunny/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f841d7999ff2bf99c3e9d019b5ccfdb7ba0d6263d48adea655175cdc3b39569
|
4
|
+
data.tar.gz: 2729e4af16616823950a1aaf5e49206c77c95567049c3f5dd956b347ef90b7ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe5a26882d6515bb1731cc3aa3f38446c7cdbc09698cb9091cc0a8b4125ec2939e41d05cd27b4293f74f00405c027a98a01fc3c7db8c9737b762fee97a4653c2
|
7
|
+
data.tar.gz: 1653165f74ef1e4e22e0bb75500a6aa5d8f17cc2879e2d08945f43366072f552fb8babe579c28d393f0f94e9db774e7b65399178893fd86ce5d878fc35a0cace
|
data/lib/bug_bunny/adapter.rb
CHANGED
@@ -17,12 +17,11 @@ module BugBunny
|
|
17
17
|
:logger,
|
18
18
|
:time_to_wait,
|
19
19
|
:communication_response,
|
20
|
-
:service_message
|
21
|
-
:consume_response
|
20
|
+
:service_message
|
22
21
|
|
23
22
|
def initialize(attrs = {})
|
24
23
|
@logger = Logger.new('./log/bug_bunny.log', 'monthly')
|
25
|
-
@communication_response = ::BugBunny::
|
24
|
+
@communication_response = ::BugBunny::Message.new(status: :error)
|
26
25
|
@time_to_wait = 2
|
27
26
|
create_adapter_with_rabbit
|
28
27
|
end
|
@@ -30,7 +29,7 @@ module BugBunny
|
|
30
29
|
def publish!(message, publish_queue, opts = {})
|
31
30
|
Timeout::timeout(TIMEOUT) do
|
32
31
|
if opts[:check_consumers_count] && publish_queue.check_consumers.zero?
|
33
|
-
self.communication_response = ::BugBunny::
|
32
|
+
self.communication_response = ::BugBunny::Message.new(status: :error, body: CONSUMER_COUNT_ZERO)
|
34
33
|
return
|
35
34
|
end
|
36
35
|
|
@@ -52,16 +51,16 @@ module BugBunny
|
|
52
51
|
rabbit.exchange.publish(message.to_json, publish_opts)
|
53
52
|
rabbit.channel.wait_for_confirms if rabbit.confirm_select
|
54
53
|
|
55
|
-
self.communication_response = ::BugBunny::
|
54
|
+
self.communication_response = ::BugBunny::Message.new(status: true)
|
56
55
|
end
|
57
56
|
rescue Timeout::Error => e
|
58
57
|
logger.error(e)
|
59
58
|
close_connection!
|
60
|
-
self.communication_response = ::BugBunny::
|
59
|
+
self.communication_response = ::BugBunny::Message.new(status: :error, body: PUBLISH_TIMEOUT, exception: e)
|
61
60
|
rescue StandardError => e
|
62
61
|
logger.error(e)
|
63
62
|
close_connection!
|
64
|
-
self.communication_response = ::BugBunny::
|
63
|
+
self.communication_response = ::BugBunny::Message.new(status: :error, body: BOMBA, exception: e)
|
65
64
|
end
|
66
65
|
|
67
66
|
def consume!(queue, thread: false, manual_ack: true, exclusive: false, block: true, opts: {})
|
@@ -125,7 +124,7 @@ module BugBunny
|
|
125
124
|
end
|
126
125
|
|
127
126
|
self.service_message = message
|
128
|
-
self.communication_response = ::BugBunny::
|
127
|
+
self.communication_response = ::BugBunny::Message.new(status: :success)
|
129
128
|
rescue ::SystemExit => e # Ensure exit code
|
130
129
|
raise e
|
131
130
|
rescue => e
|
@@ -135,7 +134,7 @@ module BugBunny
|
|
135
134
|
close_connection!
|
136
135
|
|
137
136
|
# Session.clean!
|
138
|
-
self.communication_response = ::BugBunny::
|
137
|
+
self.communication_response = ::BugBunny::Message.new(status: :error, body: BOMBA, exception: e)
|
139
138
|
end
|
140
139
|
|
141
140
|
if thread # sync consumer flag :D
|
@@ -191,12 +190,12 @@ module BugBunny
|
|
191
190
|
logger.debug("Rabbit Identifier: #{rabbit.try(:identifier)}")
|
192
191
|
logger.error(e)
|
193
192
|
close_connection!
|
194
|
-
::BugBunny::
|
193
|
+
::BugBunny::Message.new(status: :error, body: CONSUMER_TIMEOUT, exception: e)
|
195
194
|
rescue StandardError => e
|
196
195
|
logger.debug("Rabbit Identifier: #{rabbit.try(:identifier)}")
|
197
196
|
logger.error(e)
|
198
197
|
close_connection!
|
199
|
-
::BugBunny::
|
198
|
+
::BugBunny::Message.new(status: :error, body: BOMBA, exception: e)
|
200
199
|
end
|
201
200
|
|
202
201
|
def publish_and_consume!(publish_message, sync_queue, opts={})
|
@@ -278,7 +277,7 @@ module BugBunny
|
|
278
277
|
|
279
278
|
def make_response
|
280
279
|
if communication_response.success?
|
281
|
-
|
280
|
+
service_message || communication_response
|
282
281
|
else
|
283
282
|
communication_response.response = communication_response.response.to_s
|
284
283
|
communication_response
|
@@ -344,41 +343,5 @@ module BugBunny
|
|
344
343
|
close_connection!
|
345
344
|
raise Exception::ComunicationRabbitError.new(COMUNICATION_ERROR, e.backtrace)
|
346
345
|
end
|
347
|
-
|
348
|
-
def self.health_check(request: nil)
|
349
|
-
message_to_publish = ::BugBunny::Message.new(service_action: self::SERVICE_HEALTH_CHECK, body: {})
|
350
|
-
|
351
|
-
request ||= self::ROUTING_KEY_SYNC_REQUEST
|
352
|
-
|
353
|
-
begin
|
354
|
-
service_adapter = new
|
355
|
-
sync_queue = service_adapter.build_queue(
|
356
|
-
request,
|
357
|
-
self::QUEUES_PROPS[self::ROUTING_KEY_SYNC_REQUEST]
|
358
|
-
)
|
359
|
-
rescue ::BugBunny::Exception::ComunicationRabbitError => e
|
360
|
-
(service_adapter ||= nil).try(:close_connection!)
|
361
|
-
return ::BugBunny::Response.new(status: false, response: e.message)
|
362
|
-
end
|
363
|
-
|
364
|
-
service_adapter.publish_and_consume!(message_to_publish, sync_queue, check_consumers_count: true)
|
365
|
-
|
366
|
-
service_adapter.close_connection! # ensure the adapter is close
|
367
|
-
|
368
|
-
if service_adapter.communication_response.success?
|
369
|
-
msg = service_adapter.service_message
|
370
|
-
|
371
|
-
result = case msg.status
|
372
|
-
when 'success'
|
373
|
-
{ status: true }
|
374
|
-
when 'error', 'critical'
|
375
|
-
{ status: false }
|
376
|
-
end
|
377
|
-
|
378
|
-
service_adapter.consume_response = ::BugBunny::Response.new(result)
|
379
|
-
end
|
380
|
-
|
381
|
-
service_adapter.make_response
|
382
|
-
end
|
383
346
|
end
|
384
347
|
end
|
data/lib/bug_bunny/version.rb
CHANGED
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: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- gabix
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -68,7 +68,7 @@ metadata:
|
|
68
68
|
homepage_uri: https://github.com/gedera/bug_bunny
|
69
69
|
source_code_uri: https://github.com/gedera/bug_bunny
|
70
70
|
changelog_uri: https://github.com/gedera/bug_bunny/blob/main/CHANGELOG.md
|
71
|
-
post_install_message:
|
71
|
+
post_install_message:
|
72
72
|
rdoc_options: []
|
73
73
|
require_paths:
|
74
74
|
- lib
|
@@ -83,8 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
requirements: []
|
86
|
-
rubygems_version: 3.
|
87
|
-
signing_key:
|
86
|
+
rubygems_version: 3.4.1
|
87
|
+
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Gem for sync and async comunication via rabbit bunny.
|
90
90
|
test_files: []
|