rabbit_carrots 0.1.13 → 0.1.15

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: 1316749082704c2c9eb5433646e6a2789662163cdf7dfcf3a82b0537216e6c22
4
- data.tar.gz: d49a8775e4e7f2e44f3a49c1e7551d3ab17d52258b62b78d38e1b69fe76ba47d
3
+ metadata.gz: 6789a2811a7f1c151591246c4e0499c6ee5646afcf2a3127e6b6e845c66bf40b
4
+ data.tar.gz: b957f04668bc4f790478facd3a0737fea6779b5938f0d640b7b1d7edd36d8d95
5
5
  SHA512:
6
- metadata.gz: cb67259eb08808bc9d1fddb36beccaf225aea039c2155b6c5448a0204a728e0080d2ee6fff45fa3a7416453e9b6e6b23dd54f64ddf78ebb95c53eeaf1e30ad65
7
- data.tar.gz: 5b24f0137fce441674357fb0bc7971e337538aa5f34ac6e7a7ab925bfc9a4a96b06c4c53ef3b49232113f0dd4bd44c6896049652bbf817b2b5c5706658cb72c0
6
+ metadata.gz: 9a6c24f33e2490508340601b680be096d88cb97c98a656912f7cc114e3ff662fbc77958d26df05d36353140f1541534ac357a0b41f9cc07b95564130b67fbb53
7
+ data.tar.gz: 6fc7bb72c7bdafb129a200683e1b0c5822ab1e418ebfae38ce63a3aa37c344f191037eab7a379f9c136f07a2c6bcfd9b4b8becf9a06988afc5b2d8dc31c20fa7
data/Gemfile CHANGED
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
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.0'
9
9
 
10
- gem "rspec", "~> 3.0"
10
+ gem 'rspec', '~> 3.0'
11
11
 
12
- gem "rubocop", "~> 1.21"
12
+ gem 'rubocop', '~> 1.21'
13
+
14
+ gem 'rubocop-rails', '~> 2.17'
data/Gemfile.lock CHANGED
@@ -1,24 +1,34 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rabbit_carrots (0.1.13)
4
+ rabbit_carrots (0.1.15)
5
5
  bunny (>= 2.19.0)
6
6
  connection_pool (~> 2.3.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
+ activesupport (7.0.4)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
11
16
  amq-protocol (2.3.2)
12
17
  ast (2.4.2)
13
18
  bunny (2.19.0)
14
19
  amq-protocol (~> 2.3, >= 2.3.1)
15
20
  sorted_set (~> 1, >= 1.0.2)
21
+ concurrent-ruby (1.1.10)
16
22
  connection_pool (2.3.0)
17
23
  diff-lcs (1.5.0)
24
+ i18n (1.12.0)
25
+ concurrent-ruby (~> 1.0)
18
26
  json (2.6.2)
27
+ minitest (5.16.3)
19
28
  parallel (1.22.1)
20
29
  parser (3.1.2.1)
21
30
  ast (~> 2.4.1)
31
+ rack (3.0.1)
22
32
  rainbow (3.1.1)
23
33
  rake (13.0.6)
24
34
  rbtree (0.4.5)
@@ -49,11 +59,17 @@ GEM
49
59
  unicode-display_width (>= 1.4.0, < 3.0)
50
60
  rubocop-ast (1.23.0)
51
61
  parser (>= 3.1.1.0)
62
+ rubocop-rails (2.17.3)
63
+ activesupport (>= 4.2.0)
64
+ rack (>= 1.1)
65
+ rubocop (>= 1.33.0, < 2.0)
52
66
  ruby-progressbar (1.11.0)
53
67
  set (1.0.3)
54
68
  sorted_set (1.0.3)
55
69
  rbtree
56
70
  set (~> 1.0)
71
+ tzinfo (2.0.5)
72
+ concurrent-ruby (~> 1.0)
57
73
  unicode-display_width (2.3.0)
58
74
 
59
75
  PLATFORMS
@@ -64,6 +80,7 @@ DEPENDENCIES
64
80
  rake (~> 13.0)
65
81
  rspec (~> 3.0)
66
82
  rubocop (~> 1.21)
83
+ rubocop-rails (~> 2.17)
67
84
 
68
85
  BUNDLED WITH
69
- 2.3.23
86
+ 2.3.26
data/README.md CHANGED
@@ -43,6 +43,28 @@ end
43
43
 
44
44
 
45
45
 
46
+ Note that handler is a class that must implement a method named ```handle!``` that takes 4 parameters as follow:
47
+
48
+ ```ruby
49
+ class DummyEventHandler
50
+ def self.handle!(channel, delivery_info, properties, payload)
51
+ # Handle the received message from the queue
52
+ end
53
+ end
54
+ ```
55
+
56
+
57
+
58
+ Inside the handle message, you can NACK the message without re-queuing by raising ```RabbitCarrots::EventHandlers::Errors::NackMessage``` exception.
59
+
60
+ To NACK and re-queue, raise ```RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage``` exception.
61
+
62
+ If no errors are thrown, the message will be acknowledged soon after the ```handle!``` method returns.
63
+
64
+ Note: Any other unrescued exception raised inside ```handle!``` the that is a subclass of ```StandardError``` will trigger a NACK and re-queue.
65
+
66
+ ### Running
67
+
46
68
  Then run ```bundle exec rake rabbit_carrots:eat```.
47
69
 
48
70
  ## Development
data/Rakefile CHANGED
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
5
 
6
6
  RSpec::Core::RakeTask.new(:spec)
7
7
 
8
- require "rubocop/rake_task"
8
+ require 'rubocop/rake_task'
9
9
 
10
10
  RuboCop::RakeTask.new
11
11
 
@@ -4,7 +4,7 @@ module RabbitCarrots
4
4
  class Connection
5
5
  include ::Singleton
6
6
  attr_reader :connection
7
-
7
+
8
8
  def initialize
9
9
  @connection = Bunny.new(
10
10
  host: RabbitCarrots.configuration.rabbitmq_host,
@@ -16,11 +16,11 @@ module RabbitCarrots
16
16
 
17
17
  @connection.start
18
18
  end
19
-
19
+
20
20
  def channel
21
21
  @channel ||= ConnectionPool.new do
22
22
  connection.create_channel
23
23
  end
24
24
  end
25
- end
25
+ end
26
26
  end
@@ -10,4 +10,4 @@ module RabbitCarrots
10
10
  Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
11
11
  end
12
12
  end
13
- end
13
+ end
@@ -10,7 +10,7 @@ namespace :rabbit_carrots do
10
10
  { **mapping, handler: mapping[:handler].constantize }
11
11
  end
12
12
 
13
- Rails.logger = Logger.new($stdout)
13
+ Rails.logger = Logger.new(Rails.env.production? ? '/proc/self/fd/1' : $stdout)
14
14
 
15
15
  # Run RMQ Subscriber for each channel
16
16
  channels.each do |channel|
@@ -41,10 +41,10 @@ def run_task(queue_name:, handler_class:, routing_keys:)
41
41
  Rails.logger.info "Received from queue: #{queue_name}, Routing Keys: #{routing_keys}"
42
42
  handler_class.handle!(channel, delivery_info, properties, payload)
43
43
  channel.ack(delivery_info.delivery_tag, false)
44
- rescue EventHandlers::Errors::NackMessage, JSON::ParserError => _e
44
+ rescue RabbitCarrots::EventHandlers::Errors::NackMessage, JSON::ParserError => _e
45
45
  Rails.logger.info "Nacked message: #{payload}"
46
46
  channel.nack(delivery_info.delivery_tag, false, false)
47
- rescue EventHandlers::Errors::NackAndRequeueMessage => _e
47
+ rescue RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage => _e
48
48
  Rails.logger.info "Nacked and Requeued message: #{payload}"
49
49
  channel.nack(delivery_info.delivery_tag, false, true)
50
50
  rescue StandardError => e
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RabbitCarrots
4
- VERSION = "0.1.13"
4
+ VERSION = '0.1.15'
5
5
  end
@@ -1,12 +1,23 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative "rabbit_carrots/version"
3
+ require_relative 'rabbit_carrots/version'
4
4
  require 'rabbit_carrots/connection'
5
5
  require 'rabbit_carrots/configuration'
6
6
  require 'rabbit_carrots/railtie' if defined?(Rails)
7
7
 
8
-
9
8
  module RabbitCarrots
10
9
  class Error < StandardError; end
11
- # Your code goes here...
10
+
11
+ module EventHandlers
12
+ module Errors
13
+ class IrrelevantMessage < StandardError
14
+ end
15
+
16
+ class NackMessage < StandardError
17
+ end
18
+
19
+ class NackAndRequeueMessage < StandardError
20
+ end
21
+ end
22
+ end
12
23
  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.13
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brusk Awat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-12-01 00:00:00.000000000 Z
11
+ date: 2023-01-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -69,6 +69,7 @@ metadata:
69
69
  homepage_uri: https://github.com/ditkrg
70
70
  source_code_uri: https://github.com/ditkrg/rabbit_carrots
71
71
  changelog_uri: https://github.com/ditkrg/rabbit_carrots
72
+ rubygems_mfa_required: 'true'
72
73
  post_install_message:
73
74
  rdoc_options: []
74
75
  require_paths: