rabbit_carrots 1.0.5 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '087c6969469ec2ca854c1a85453bb9d81285d435d3c2b71b16382eda48b95782'
4
- data.tar.gz: 8d729d8a6bd6e3dfe19fd50ce616a92b3a93e482757cbcda1e01441cf68fcfeb
3
+ metadata.gz: f8e5f321b0b92e7e1c3f1926e28b692398fd453e22c591ad0715fa7bc93b1b34
4
+ data.tar.gz: 5be7f4d4378c6a0fdc4f2edbec9fd438dca66a98ec1b9659d6a6a44d8d4d3cb4
5
5
  SHA512:
6
- metadata.gz: 202b90068c8606e61ebc3fe8b43162e34af622e23e37b79b28fa677b03ed579ab47433d1eaef860fe6a658922cf8cf59d98b14797b8ea6d0b944902aa4d8dbf0
7
- data.tar.gz: 703b749ea0fb250f377f796a9f547ebbfc91ae9295dc71c2df90a06620080578b02298ce0ac79e227ee0153ea87762f08554e80eb43a83bd92ec04777b40ecf8
6
+ metadata.gz: 83bde341ce60aaaee1bcfd1c323484641fcfbc7e2d8b74fcd34ef0afe7eb91dc9d332254f34049dfe5b24120bfb717bf1d7cdc758130481059fcd9b1b5a7d848
7
+ data.tar.gz: 585ff0eb908008acdc9b323dd138dcb676955c2c87586f62d71d7926c534cfe988c1e071ae2b308455299a3a1672123ea054a5a70f2abea3194fad2456f38af4
data/.rubocop.yml CHANGED
@@ -1,11 +1,12 @@
1
- require: rubocop-rails
1
+ plugins:
2
+ - rubocop-rails
2
3
 
3
4
  AllCops:
4
5
  NewCops: enable
5
6
  SuggestExtensions: false
6
7
  Layout/SpaceBeforeBrackets: # (new in 1.7)
7
8
  Enabled: true
8
- Layout/LineLength:
9
+ Layout/LineLength:
9
10
  Max: 350
10
11
  Lint/AmbiguousAssignment: # (new in 1.7)
11
12
  Enabled: true
@@ -110,4 +111,6 @@ Metrics/MethodLength:
110
111
  Metrics/CyclomaticComplexity:
111
112
  Max: 15
112
113
  Metrics/PerceivedComplexity:
113
- Max: 15
114
+ Max: 15
115
+ Metrics/ParameterLists:
116
+ Max: 6
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.1'
8
+ gem 'rake', '~> 13.3.1'
9
9
 
10
- gem 'rspec', '~> 3.12'
10
+ gem 'rspec', '~> 3.13.2'
11
11
 
12
- gem 'rubocop', '~> 1.58'
12
+ gem 'rubocop', '~> 1.82.1'
13
13
 
14
- gem 'rubocop-rails', '~> 2.22'
14
+ gem 'rubocop-rails', '~> 2.34.3'
data/Gemfile.lock CHANGED
@@ -1,102 +1,112 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rabbit_carrots (1.0.4)
4
+ rabbit_carrots (1.1.0)
5
5
  bunny (>= 2.22)
6
- connection_pool (~> 2.4)
6
+ connection_pool (>= 2.4)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- activesupport (7.1.2)
11
+ activesupport (8.1.2)
12
12
  base64
13
13
  bigdecimal
14
- concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ concurrent-ruby (~> 1.0, >= 1.3.1)
15
15
  connection_pool (>= 2.2.5)
16
16
  drb
17
17
  i18n (>= 1.6, < 2)
18
+ json
19
+ logger (>= 1.4.2)
18
20
  minitest (>= 5.1)
19
- mutex_m
20
- tzinfo (~> 2.0)
21
- amq-protocol (2.3.4)
22
- ast (2.4.2)
23
- base64 (0.2.0)
24
- bigdecimal (3.1.4)
21
+ securerandom (>= 0.3)
22
+ tzinfo (~> 2.0, >= 2.0.5)
23
+ uri (>= 0.13.1)
24
+ amq-protocol (2.5.0)
25
+ ast (2.4.3)
26
+ base64 (0.3.0)
27
+ bigdecimal (4.0.1)
25
28
  bunny (2.24.0)
26
29
  amq-protocol (~> 2.3)
27
30
  sorted_set (~> 1, >= 1.0.2)
28
- concurrent-ruby (1.2.2)
29
- connection_pool (2.4.1)
30
- diff-lcs (1.5.0)
31
- drb (2.2.0)
32
- ruby2_keywords
33
- i18n (1.14.1)
31
+ concurrent-ruby (1.3.6)
32
+ connection_pool (3.0.2)
33
+ diff-lcs (1.6.2)
34
+ drb (2.2.3)
35
+ i18n (1.14.8)
34
36
  concurrent-ruby (~> 1.0)
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)
37
+ json (2.18.0)
38
+ language_server-protocol (3.17.0.5)
39
+ lint_roller (1.1.0)
40
+ logger (1.7.0)
41
+ minitest (6.0.1)
42
+ prism (~> 1.5)
43
+ parallel (1.27.0)
44
+ parser (3.3.10.1)
41
45
  ast (~> 2.4.1)
42
46
  racc
43
- racc (1.7.3)
44
- rack (3.0.8)
47
+ prism (1.8.0)
48
+ racc (1.8.1)
49
+ rack (3.2.4)
45
50
  rainbow (3.1.1)
46
- rake (13.1.0)
51
+ rake (13.3.1)
47
52
  rbtree (0.4.6)
48
- regexp_parser (2.8.3)
49
- rexml (3.2.6)
50
- rspec (3.12.0)
51
- rspec-core (~> 3.12.0)
52
- rspec-expectations (~> 3.12.0)
53
- rspec-mocks (~> 3.12.0)
54
- rspec-core (3.12.0)
55
- rspec-support (~> 3.12.0)
56
- rspec-expectations (3.12.0)
53
+ regexp_parser (2.11.3)
54
+ rspec (3.13.2)
55
+ rspec-core (~> 3.13.0)
56
+ rspec-expectations (~> 3.13.0)
57
+ rspec-mocks (~> 3.13.0)
58
+ rspec-core (3.13.6)
59
+ rspec-support (~> 3.13.0)
60
+ rspec-expectations (3.13.5)
57
61
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.12.0)
59
- rspec-mocks (3.12.0)
62
+ rspec-support (~> 3.13.0)
63
+ rspec-mocks (3.13.7)
60
64
  diff-lcs (>= 1.2.0, < 2.0)
61
- rspec-support (~> 3.12.0)
62
- rspec-support (3.12.0)
63
- rubocop (1.58.0)
65
+ rspec-support (~> 3.13.0)
66
+ rspec-support (3.13.6)
67
+ rubocop (1.82.1)
64
68
  json (~> 2.3)
65
- language_server-protocol (>= 3.17.0)
69
+ language_server-protocol (~> 3.17.0.2)
70
+ lint_roller (~> 1.1.0)
66
71
  parallel (~> 1.10)
67
- parser (>= 3.2.2.4)
72
+ parser (>= 3.3.0.2)
68
73
  rainbow (>= 2.2.2, < 4.0)
69
- regexp_parser (>= 1.8, < 3.0)
70
- rexml (>= 3.2.5, < 4.0)
71
- rubocop-ast (>= 1.30.0, < 2.0)
74
+ regexp_parser (>= 2.9.3, < 3.0)
75
+ rubocop-ast (>= 1.48.0, < 2.0)
72
76
  ruby-progressbar (~> 1.7)
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)
77
+ unicode-display_width (>= 2.4.0, < 4.0)
78
+ rubocop-ast (1.49.0)
79
+ parser (>= 3.3.7.2)
80
+ prism (~> 1.7)
81
+ rubocop-rails (2.34.3)
77
82
  activesupport (>= 4.2.0)
83
+ lint_roller (~> 1.1)
78
84
  rack (>= 1.1)
79
- rubocop (>= 1.33.0, < 2.0)
80
- rubocop-ast (>= 1.30.0, < 2.0)
85
+ rubocop (>= 1.75.0, < 2.0)
86
+ rubocop-ast (>= 1.44.0, < 2.0)
81
87
  ruby-progressbar (1.13.0)
82
- ruby2_keywords (0.0.5)
88
+ securerandom (0.4.1)
83
89
  set (1.1.2)
84
90
  sorted_set (1.0.3)
85
91
  rbtree
86
92
  set (~> 1.0)
87
93
  tzinfo (2.0.6)
88
94
  concurrent-ruby (~> 1.0)
89
- unicode-display_width (2.5.0)
95
+ unicode-display_width (3.2.0)
96
+ unicode-emoji (~> 4.1)
97
+ unicode-emoji (4.2.0)
98
+ uri (1.1.1)
90
99
 
91
100
  PLATFORMS
101
+ arm64-darwin-25
92
102
  x86_64-linux
93
103
 
94
104
  DEPENDENCIES
95
105
  rabbit_carrots!
96
- rake (~> 13.1)
97
- rspec (~> 3.12)
98
- rubocop (~> 1.58)
99
- rubocop-rails (~> 2.22)
106
+ rake (~> 13.3.1)
107
+ rspec (~> 3.13.2)
108
+ rubocop (~> 1.82.1)
109
+ rubocop-rails (~> 2.34.3)
100
110
 
101
111
  BUNDLED WITH
102
112
  2.3.26
@@ -1,4 +1,5 @@
1
1
  # rabbit_carrots.rb
2
+ require 'English'
2
3
  require 'puma/plugin'
3
4
  require 'rabbit_carrots'
4
5
 
@@ -7,7 +8,7 @@ Puma::Plugin.create do
7
8
 
8
9
  def start(launcher)
9
10
  @log_writer = launcher.log_writer
10
- @puma_pid = $$
11
+ @puma_pid = $PROCESS_ID
11
12
 
12
13
  @core_service = RabbitCarrots::Core.new(logger: log_writer)
13
14
 
@@ -57,7 +58,7 @@ Puma::Plugin.create do
57
58
  loop do
58
59
  if send(process_dead)
59
60
  log message
60
- Process.kill('TERM', $$)
61
+ Process.kill('TERM', $PROCESS_ID)
61
62
  break
62
63
  end
63
64
  sleep 2
@@ -24,8 +24,6 @@ module RabbitCarrots
24
24
  @orm ||= :activerecord
25
25
  end
26
26
 
27
- def orm=(value)
28
- @orm = value
29
- end
27
+ attr_writer :orm
30
28
  end
31
29
  end
@@ -3,6 +3,7 @@ require 'singleton'
3
3
  module RabbitCarrots
4
4
  class Connection
5
5
  include ::Singleton
6
+
6
7
  attr_reader :connection
7
8
 
8
9
  def initialize
@@ -1,5 +1,5 @@
1
1
  module RabbitCarrots
2
- class Core
2
+ class Core # rubocop:disable Metrics/ClassLength
3
3
  attr_reader :logger
4
4
 
5
5
  @database_agnostic_not_null_violation = nil
@@ -36,6 +36,7 @@ module RabbitCarrots
36
36
  handler_class:,
37
37
  routing_keys: channel[:routing_keys],
38
38
  queue_arguments: channel[:arguments],
39
+ exchange_name: channel[:exchange_name],
39
40
  kill_to_restart_on_standard_error:
40
41
  )
41
42
  end
@@ -76,9 +77,9 @@ module RabbitCarrots
76
77
  @running = false
77
78
  end
78
79
 
79
- def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {}, kill_to_restart_on_standard_error: false)
80
+ def run_task(queue_name:, handler_class:, routing_keys:, queue_arguments: {}, exchange_name: nil, kill_to_restart_on_standard_error: false)
80
81
  RabbitCarrots::Connection.instance.channel.with do |channel|
81
- exchange = channel.topic(RabbitCarrots.configuration.rabbitmq_exchange_name, durable: true)
82
+ exchange = channel.topic(exchange_name || RabbitCarrots.configuration.rabbitmq_exchange_name, durable: true)
82
83
 
83
84
  logger.info "Listening on QUEUE: #{queue_name} for ROUTING KEYS: #{routing_keys}"
84
85
  queue = channel.queue(queue_name, durable: true, arguments: queue_arguments)
@@ -92,19 +93,24 @@ module RabbitCarrots
92
93
  handler_class.handle!(channel, delivery_info, properties, payload)
93
94
  channel.ack(delivery_info.delivery_tag, false)
94
95
  rescue RabbitCarrots::EventHandlers::Errors::NackMessage, JSON::ParserError => _e
96
+ payload = encode_payload(payload)
95
97
  logger.warn "Nacked message: #{payload}"
96
98
  channel.nack(delivery_info.delivery_tag, false, false)
97
99
  rescue RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage => _e
100
+ payload = encode_payload(payload)
98
101
  logger.warn "Nacked and Requeued message: #{payload}"
99
102
  channel.nack(delivery_info.delivery_tag, false, true)
100
103
  rescue self.class.database_agnostic_not_null_violation, self.class.database_agnostic_record_invalid => e
104
+ payload = encode_payload(payload)
101
105
  logger.warn "Null constraint or Invalid violation: #{payload}. Error: #{e.message}"
102
106
  channel.ack(delivery_info.delivery_tag, false)
103
107
  rescue self.class.database_agnostic_connection_not_established => e
108
+ payload = encode_payload(payload)
104
109
  logger.warn "Error connection not established to the database: #{payload}. Error: #{e.message}"
105
110
  sleep 3
106
111
  channel.nack(delivery_info.delivery_tag, false, true)
107
112
  rescue StandardError => e
113
+ payload = encode_payload(payload)
108
114
  logger.error "Error handling message: #{payload}. Error: #{e.message}"
109
115
  sleep 3
110
116
  channel.nack(delivery_info.delivery_tag, false, true)
@@ -137,5 +143,14 @@ module RabbitCarrots
137
143
  adapter.instance_variable_set(:@logger, logger)
138
144
  adapter
139
145
  end
146
+
147
+ def encode_payload(payload)
148
+ payload.encode(
149
+ 'UTF-8',
150
+ invalid: :replace,
151
+ undef: :replace,
152
+ replace: ''
153
+ )
154
+ end
140
155
  end
141
156
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RabbitCarrots
4
- VERSION = '1.0.5'
4
+ VERSION = '1.1.0'
5
5
  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: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brusk Awat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-18 00:00:00.000000000 Z
11
+ date: 2026-01-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: connection_pool
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
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
40
  version: '2.4'
41
41
  description: A background task based on rake to consume RabbitMQ messages