bug_bunny 0.2.2 → 0.2.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: daaffb39ad9bdde817c106114b90ce45b7807b1e77d4c411846506618791bece
4
- data.tar.gz: d578e38d4faf58d2f23514d641ba01a40a43f8f723a9ab4640a2c6cb97c9d657
3
+ metadata.gz: 0f841d7999ff2bf99c3e9d019b5ccfdb7ba0d6263d48adea655175cdc3b39569
4
+ data.tar.gz: 2729e4af16616823950a1aaf5e49206c77c95567049c3f5dd956b347ef90b7ab
5
5
  SHA512:
6
- metadata.gz: bac312aee21baa512994dadf9807225012b3a3cedb91956df52da97680432d2d955045700d4b2012dbc4ed2a7bf69b5a0d14a7f464fd1ae17001e7d7e0a01420
7
- data.tar.gz: a9e4feea6301be2aadcc5551fcc085caeb36747dc6f2d9d792126f904e29befbbea2433d36b833956a37508cfe3be72d403f2d264656cf86ef3fed453cfd4d23
6
+ metadata.gz: fe5a26882d6515bb1731cc3aa3f38446c7cdbc09698cb9091cc0a8b4125ec2939e41d05cd27b4293f74f00405c027a98a01fc3c7db8c9737b762fee97a4653c2
7
+ data.tar.gz: 1653165f74ef1e4e22e0bb75500a6aa5d8f17cc2879e2d08945f43366072f552fb8babe579c28d393f0f94e9db774e7b65399178893fd86ce5d878fc35a0cace
@@ -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::Response.new status: false
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::Response.new(status: false, response: CONSUMER_COUNT_ZERO)
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::Response.new(status: true)
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::Response.new(status: false, response: PUBLISH_TIMEOUT, exception: e)
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::Response.new(status: false, response: BOMBA, exception: e)
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::Response.new(status: true)
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::Response.new(status: false, response: BOMBA, exception: e)
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::Response.new(status: false, response: CONSUMER_TIMEOUT, exception: e)
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::Response.new(status: false, response: BOMBA, exception: e)
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
- consume_response || communication_response
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BugBunny
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.4"
5
5
  end
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.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-07-28 00:00:00.000000000 Z
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.5.11
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: []