rabbit_carrots 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/puma/plugin/rabbit_carrots.rb +1 -0
- data/lib/rabbit_carrots/configuration.rb +5 -1
- data/lib/rabbit_carrots/core.rb +13 -7
- data/lib/rabbit_carrots/errors.rb +18 -0
- data/lib/rabbit_carrots/version.rb +1 -1
- data/lib/rabbit_carrots.rb +2 -17
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 512be53850324ba32bfdf38f6069561fb4cff9cd3e21c7acd3f431ade7533603
|
4
|
+
data.tar.gz: 297df24712a1eed2dd55902845ade84a1d44b714f69c75a1ac97be98baf15de8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 260c156c6794fc7b3c92ccd1f946c47e3ad004c01ec15f0bdd1875812d030a4d3983b67ed6106041370e97840db22da65afac2fe17d682cc97267ac926a17c2c
|
7
|
+
data.tar.gz: 7ddc79c2c86c6db3fda8f3ec20cd9cac7750b054c01a0a96837ff9a02af5290e774718c6bb7b54d520fd3fd972a9e1bba5c614fa530c0cbb98f5f06542aa3ed8
|
data/Gemfile.lock
CHANGED
data/lib/rabbit_carrots/core.rb
CHANGED
@@ -2,9 +2,13 @@ module RabbitCarrots
|
|
2
2
|
class Core
|
3
3
|
attr_reader :logger
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
@database_agnostic_not_null_violation = nil
|
6
|
+
@database_agnostic_connection_not_established = nil
|
7
|
+
@database_agnostic_record_invalid = nil
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :database_agnostic_not_null_violation, :database_agnostic_connection_not_established, :database_agnostic_record_invalid
|
11
|
+
end
|
8
12
|
|
9
13
|
def initialize(logger: nil)
|
10
14
|
@logger = logger || Logger.new(Rails.env.production? ? '/proc/self/fd/1' : $stdout)
|
@@ -14,6 +18,10 @@ module RabbitCarrots
|
|
14
18
|
end
|
15
19
|
|
16
20
|
def start(kill_to_restart_on_standard_error: false)
|
21
|
+
self.class.database_agnostic_not_null_violation = RabbitCarrots.configuration.orm == :activerecord ? ActiveRecord::NotNullViolation : RabbitCarrots::EventHandlers::Errors::PlaceholderError
|
22
|
+
self.class.database_agnostic_connection_not_established = RabbitCarrots.configuration.orm == :activerecord ? ActiveRecord::ConnectionNotEstablished : ::Mongo::Error::SocketError
|
23
|
+
self.class.database_agnostic_record_invalid = RabbitCarrots.configuration.orm == :activerecord ? ActiveRecord::RecordInvalid : ::Mongoid::Errors::Validations
|
24
|
+
|
17
25
|
channels = RabbitCarrots.configuration.routing_key_mappings.map do |mapping|
|
18
26
|
{ **mapping, handler: mapping[:handler].constantize }
|
19
27
|
end
|
@@ -89,10 +97,10 @@ module RabbitCarrots
|
|
89
97
|
rescue RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage => _e
|
90
98
|
logger.log "Nacked and Requeued message: #{payload}"
|
91
99
|
channel.nack(delivery_info.delivery_tag, false, true)
|
92
|
-
rescue
|
100
|
+
rescue self.class.database_agnostic_not_null_violation, self.class.database_agnostic_record_invalid => e
|
93
101
|
logger.log "Null constraint or Invalid violation: #{payload}. Error: #{e.message}"
|
94
102
|
channel.ack(delivery_info.delivery_tag, false)
|
95
|
-
rescue
|
103
|
+
rescue self.class.database_agnostic_connection_not_established => e
|
96
104
|
logger.log "Error connection not established to the database: #{payload}. Error: #{e.message}"
|
97
105
|
sleep 3
|
98
106
|
channel.nack(delivery_info.delivery_tag, false, true)
|
@@ -102,8 +110,6 @@ module RabbitCarrots
|
|
102
110
|
channel.nack(delivery_info.delivery_tag, false, true)
|
103
111
|
Process.kill('SIGTERM', Process.pid) if kill_to_restart_on_standard_error
|
104
112
|
end
|
105
|
-
|
106
|
-
logger.log "Ending task for queue: #{queue_name}"
|
107
113
|
end
|
108
114
|
rescue StandardError => e
|
109
115
|
logger.error "Bunny session error: #{e.message}"
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module RabbitCarrots
|
2
|
+
class Error < StandardError; end
|
3
|
+
|
4
|
+
module EventHandlers
|
5
|
+
module Errors
|
6
|
+
class IrrelevantMessage < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
class NackMessage < StandardError
|
10
|
+
end
|
11
|
+
|
12
|
+
class NackAndRequeueMessage < StandardError
|
13
|
+
end
|
14
|
+
|
15
|
+
class PlaceholderError < Error; end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/rabbit_carrots.rb
CHANGED
@@ -1,26 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require_relative 'rabbit_carrots/version'
|
4
|
+
require 'rabbit_carrots/errors'
|
4
5
|
require 'rabbit_carrots/connection'
|
5
|
-
require 'rabbit_carrots/core'
|
6
6
|
require 'rabbit_carrots/configuration'
|
7
7
|
require 'rabbit_carrots/railtie' if defined?(Rails)
|
8
|
+
require 'rabbit_carrots/core'
|
8
9
|
|
9
10
|
module RabbitCarrots
|
10
|
-
class Error < StandardError; end
|
11
|
-
|
12
|
-
module EventHandlers
|
13
|
-
module Errors
|
14
|
-
class IrrelevantMessage < StandardError
|
15
|
-
end
|
16
|
-
|
17
|
-
class NackMessage < StandardError
|
18
|
-
end
|
19
|
-
|
20
|
-
class NackAndRequeueMessage < StandardError
|
21
|
-
end
|
22
|
-
|
23
|
-
class PlaceholderError < Error; end
|
24
|
-
end
|
25
|
-
end
|
26
11
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_carrots
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brusk Awat
|
@@ -59,6 +59,7 @@ files:
|
|
59
59
|
- lib/rabbit_carrots/configuration.rb
|
60
60
|
- lib/rabbit_carrots/connection.rb
|
61
61
|
- lib/rabbit_carrots/core.rb
|
62
|
+
- lib/rabbit_carrots/errors.rb
|
62
63
|
- lib/rabbit_carrots/railtie.rb
|
63
64
|
- lib/rabbit_carrots/tasks/rmq.rake
|
64
65
|
- lib/rabbit_carrots/version.rb
|