rabbit_carrots 0.1.18 → 0.1.20

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: c9fb1f67171e4f18f2e1640592ce820233d76456b78b764e72f8b4a811b85383
4
- data.tar.gz: 535403deef2e78e75be7ddc1572bd7773d464b55061e5f3a7ac5265b5e37309c
3
+ metadata.gz: 9e3aa34b3f6e19e3490fcba113867feb0326fd10e8597b9323d8f384a36caa55
4
+ data.tar.gz: 972c341f20e6bcd7d84c7cae441938f6f0f8fef2451bcb84f41f9e1d4b331e0b
5
5
  SHA512:
6
- metadata.gz: d5f04fe09bbc7bb71fa85237e526cb011f039e6010547ab3d27de1abdb4b98892bf256cc33b380a353e7482852f3e90cd9fb7255f757a0391961ffa140e679d6
7
- data.tar.gz: 3b7c2b59a8bfd51d1ce2a26886afd46049df699f876e9afd2c810e22ad17e75e579e6790cc6db1b91dd45e6150fa73f5aaedcbe7f4968afc9daef9eaafe2e571
6
+ metadata.gz: 6b6df93150a9535d8acff68628c548958e9f22f23cb87d183460d38672d0a135e718e840df92fd70899e2deea5e8482a17d11b5ae6b6862510a8bec3cc853855
7
+ data.tar.gz: 5100eab0c16d895dbc0c8e0dbf0217a49d2d37e965ab8a955c543eb657f87eab1b281d09c80908b641720b792a891cc1dd1d5db8b232144627410eea167e7bf0
data/Gemfile CHANGED
@@ -5,10 +5,10 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in rabbit_carrots.gemspec
6
6
  gemspec
7
7
 
8
- gem 'rake', '~> 13.0'
8
+ gem 'rake', '~> 13.1'
9
9
 
10
- gem 'rspec', '~> 3.0'
10
+ gem 'rspec', '~> 3.12'
11
11
 
12
- gem 'rubocop', '~> 1.21'
12
+ gem 'rubocop', '~> 1.58'
13
13
 
14
- gem 'rubocop-rails', '~> 2.17'
14
+ gem 'rubocop-rails', '~> 2.22'
data/Gemfile.lock CHANGED
@@ -1,39 +1,52 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rabbit_carrots (0.1.17)
5
- bunny (>= 2.19.0)
6
- connection_pool (~> 2.3.0)
4
+ rabbit_carrots (0.1.20)
5
+ bunny (>= 2.22)
6
+ connection_pool (~> 2.4)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.0.4)
11
+ activesupport (7.1.2)
12
+ base64
13
+ bigdecimal
12
14
  concurrent-ruby (~> 1.0, >= 1.0.2)
15
+ connection_pool (>= 2.2.5)
16
+ drb
13
17
  i18n (>= 1.6, < 2)
14
18
  minitest (>= 5.1)
19
+ mutex_m
15
20
  tzinfo (~> 2.0)
16
21
  amq-protocol (2.3.2)
17
22
  ast (2.4.2)
18
- bunny (2.20.3)
23
+ base64 (0.2.0)
24
+ bigdecimal (3.1.4)
25
+ bunny (2.22.0)
19
26
  amq-protocol (~> 2.3, >= 2.3.1)
20
27
  sorted_set (~> 1, >= 1.0.2)
21
- concurrent-ruby (1.1.10)
22
- connection_pool (2.3.0)
28
+ concurrent-ruby (1.2.2)
29
+ connection_pool (2.4.1)
23
30
  diff-lcs (1.5.0)
24
- i18n (1.12.0)
31
+ drb (2.2.0)
32
+ ruby2_keywords
33
+ i18n (1.14.1)
25
34
  concurrent-ruby (~> 1.0)
26
- json (2.6.2)
27
- minitest (5.16.3)
28
- parallel (1.22.1)
29
- parser (3.1.2.1)
35
+ json (2.7.1)
36
+ language_server-protocol (3.17.0.3)
37
+ minitest (5.20.0)
38
+ mutex_m (0.2.0)
39
+ parallel (1.23.0)
40
+ parser (3.2.2.4)
30
41
  ast (~> 2.4.1)
31
- rack (3.0.4.2)
42
+ racc
43
+ racc (1.7.3)
44
+ rack (3.0.8)
32
45
  rainbow (3.1.1)
33
- rake (13.0.6)
46
+ rake (13.1.0)
34
47
  rbtree (0.4.6)
35
- regexp_parser (2.6.1)
36
- rexml (3.2.5)
48
+ regexp_parser (2.8.3)
49
+ rexml (3.2.6)
37
50
  rspec (3.12.0)
38
51
  rspec-core (~> 3.12.0)
39
52
  rspec-expectations (~> 3.12.0)
@@ -47,40 +60,43 @@ GEM
47
60
  diff-lcs (>= 1.2.0, < 2.0)
48
61
  rspec-support (~> 3.12.0)
49
62
  rspec-support (3.12.0)
50
- rubocop (1.39.0)
63
+ rubocop (1.58.0)
51
64
  json (~> 2.3)
65
+ language_server-protocol (>= 3.17.0)
52
66
  parallel (~> 1.10)
53
- parser (>= 3.1.2.1)
67
+ parser (>= 3.2.2.4)
54
68
  rainbow (>= 2.2.2, < 4.0)
55
69
  regexp_parser (>= 1.8, < 3.0)
56
70
  rexml (>= 3.2.5, < 4.0)
57
- rubocop-ast (>= 1.23.0, < 2.0)
71
+ rubocop-ast (>= 1.30.0, < 2.0)
58
72
  ruby-progressbar (~> 1.7)
59
- unicode-display_width (>= 1.4.0, < 3.0)
60
- rubocop-ast (1.23.0)
61
- parser (>= 3.1.1.0)
62
- rubocop-rails (2.17.3)
73
+ unicode-display_width (>= 2.4.0, < 3.0)
74
+ rubocop-ast (1.30.0)
75
+ parser (>= 3.2.1.0)
76
+ rubocop-rails (2.22.2)
63
77
  activesupport (>= 4.2.0)
64
78
  rack (>= 1.1)
65
79
  rubocop (>= 1.33.0, < 2.0)
66
- ruby-progressbar (1.11.0)
80
+ rubocop-ast (>= 1.30.0, < 2.0)
81
+ ruby-progressbar (1.13.0)
82
+ ruby2_keywords (0.0.5)
67
83
  set (1.0.3)
68
84
  sorted_set (1.0.3)
69
85
  rbtree
70
86
  set (~> 1.0)
71
- tzinfo (2.0.5)
87
+ tzinfo (2.0.6)
72
88
  concurrent-ruby (~> 1.0)
73
- unicode-display_width (2.3.0)
89
+ unicode-display_width (2.5.0)
74
90
 
75
91
  PLATFORMS
76
92
  x86_64-linux
77
93
 
78
94
  DEPENDENCIES
79
95
  rabbit_carrots!
80
- rake (~> 13.0)
81
- rspec (~> 3.0)
82
- rubocop (~> 1.21)
83
- rubocop-rails (~> 2.17)
96
+ rake (~> 13.1)
97
+ rspec (~> 3.12)
98
+ rubocop (~> 1.58)
99
+ rubocop-rails (~> 2.22)
84
100
 
85
101
  BUNDLED WITH
86
102
  2.3.26
data/README.md CHANGED
@@ -32,7 +32,7 @@ RabbitCarrots.configure do |c|
32
32
  c.rabbitmq_user = ENV.fetch('RABBITMQ__USER', nil)
33
33
  c.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD', nil)
34
34
  c.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST', nil)
35
- c.event_bus_exchange_name = ENV.fetch('EVENTBUS__EXCHANGE_NAME', nil)
35
+ c.rabbitmq_exchange_name = ENV.fetch('RABBITMQ__EXCHANGE_NAME', nil)
36
36
  c.routing_key_mappings = [
37
37
  { routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' },
38
38
  { routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' }
@@ -9,6 +9,6 @@ module RabbitCarrots
9
9
  end
10
10
 
11
11
  class Configuration
12
- attr_accessor :rabbitmq_host, :rabbitmq_port, :rabbitmq_user, :rabbitmq_password, :rabbitmq_vhost, :routing_key_mappings, :event_bus_exchange_name
12
+ attr_accessor :rabbitmq_host, :rabbitmq_port, :rabbitmq_user, :rabbitmq_password, :rabbitmq_vhost, :routing_key_mappings, :rabbitmq_exchange_name
13
13
  end
14
14
  end
@@ -5,6 +5,12 @@ namespace :rabbit_carrots do
5
5
  task eat: :environment do
6
6
  Rails.application.eager_load!
7
7
 
8
+ # rubocop:disable Lint/ConstantDefinitionInBlock
9
+ DatabaseAgonsticNotNullViolation = defined?(ActiveRecord) ? ActiveRecord::NotNullViolation : RabbitCarrots::EventHandlers::Errors::PlaceholderError
10
+ DatabaseAgonsticConnectionNotEstablished = defined?(ActiveRecord) ? ActiveRecord::ConnectionNotEstablished : Mongo::Error::SocketError
11
+ DatabaseAgnosticRecordInvalid = defined?(ActiveRecord) ? ActiveRecord::RecordInvalid : Mongoid::Errors::Validations
12
+ # rubocop:enable Lint/ConstantDefinitionInBlock
13
+
8
14
  channels = RabbitCarrots.configuration.routing_key_mappings.map do |mapping|
9
15
  # This will be supplied in initializer. At that time, the Handler will not be available to be loaded and will throw Uninitialized Constant
10
16
  { **mapping, handler: mapping[:handler].constantize }
@@ -28,9 +34,9 @@ namespace :rabbit_carrots do
28
34
  end
29
35
  end
30
36
 
31
- def run_task(queue_name:, queue_arguments: {}, handler_class:, routing_keys:)
37
+ def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {})
32
38
  RabbitCarrots::Connection.instance.channel.with do |channel|
33
- exchange = channel.topic(RabbitCarrots.configuration.event_bus_exchange_name, durable: true)
39
+ exchange = channel.topic(RabbitCarrots.configuration.rabbitmq_exchange_name, durable: true)
34
40
 
35
41
  Rails.logger.info "Listening on QUEUE: #{queue_name} for ROUTING KEYS: #{routing_keys}"
36
42
  queue = channel.queue(queue_name, durable: true, arguments: queue_arguments)
@@ -47,11 +53,11 @@ def run_task(queue_name:, queue_arguments: {}, handler_class:, routing_keys:)
47
53
  rescue RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage => _e
48
54
  Rails.logger.info "Nacked and Requeued message: #{payload}"
49
55
  channel.nack(delivery_info.delivery_tag, false, true)
50
- rescue ActiveRecord::NotNullViolation, ActiveRecord::RecordInvalid => e
56
+ rescue DatabaseAgonsticNotNullViolation, DatabaseAgnosticRecordInvalid => e
51
57
  # on null constraint violation, we want to ack the message
52
58
  Rails.logger.error "Null constraint or Invalid violation: #{payload}. Error: #{e.message}"
53
59
  channel.ack(delivery_info.delivery_tag, false)
54
- rescue ActiveRecord::ConnectionNotEstablished => e
60
+ rescue DatabaseAgonsticConnectionNotEstablished => e
55
61
  # on connection not established, we want to requeue the message and sleep for 3 seconds
56
62
  Rails.logger.error "Error connection not established to the database: #{payload}. Error: #{e.message}"
57
63
  # delay for 3 seconds before requeuing
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RabbitCarrots
4
- VERSION = '0.1.18'
4
+ VERSION = '0.1.20'
5
5
  end
@@ -18,6 +18,8 @@ module RabbitCarrots
18
18
 
19
19
  class NackAndRequeueMessage < StandardError
20
20
  end
21
+
22
+ class PlaceholderError < Error; end
21
23
  end
22
24
  end
23
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_carrots
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.18
4
+ version: 0.1.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brusk Awat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-29 00:00:00.000000000 Z
11
+ date: 2023-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 2.19.0
19
+ version: '2.22'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 2.19.0
26
+ version: '2.22'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: connection_pool
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.3.0
33
+ version: '2.4'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.3.0
40
+ version: '2.4'
41
41
  description: A background task based on rake to consume RabbitMQ messages
42
42
  email:
43
43
  - broosk.edogawa@gmail.com
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
85
85
  - !ruby/object:Gem::Version
86
86
  version: '0'
87
87
  requirements: []
88
- rubygems_version: 3.4.1
88
+ rubygems_version: 3.4.19
89
89
  signing_key:
90
90
  specification_version: 4
91
91
  summary: A simple RabbitMQ consumer task