bug_bunny 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bug_bunny/adapter.rb +2 -39
- data/lib/bug_bunny/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 44a4635e06b113a429bf55f1d1d9d26ecd106fdfe9bd91d2feb975352f5905a1
|
4
|
+
data.tar.gz: 1006a577430270652be5f21a8215dea9777f423b85fdc2f699c1903560ea2864
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 84699963ef67a52f7c50b0e934818d17ee6fb0e177594d99d4f11fd522e88475cc3bbf229285011e9b5e6e6d92b9225fe1700d796b3778a66eb5b9d7f15badd1
|
7
|
+
data.tar.gz: 28e10b78f4def1df46779b0abac6624ee1ead627d0c992c2b3eec97cb770d8344bcce4568eb7e4f5592995fb5970fb1995606523c37a70cfd8e9992680baa590
|
data/lib/bug_bunny/adapter.rb
CHANGED
@@ -17,8 +17,7 @@ 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')
|
@@ -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