rabbit_carrots 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 85615e674f692fc6fb73086da7c4bdc1b8d400c200bad8aa7a4881897ade2f1a
4
+ data.tar.gz: debfe058918838e97b7082afcaf63bfbd9bbac73f58d83320038dcd2e94e84f5
5
+ SHA512:
6
+ metadata.gz: 06e0bbde5816f4f189a4a14d3e77c49303de75e185a9336f4f0a90926b74e17d3bfd96bf6593bfea400520d3ed1120d6930d8af203d03582d7d21671610b70e0
7
+ data.tar.gz: 6b566bf68ab9a214e3802212b88bcd284f8387f2503af6731662bfae2ac9c2c911bb0793641e439324b6910e8ba3331a16ef50ea2d78ab35590a51021f98adad
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,113 @@
1
+ require: rubocop-rails
2
+
3
+ AllCops:
4
+ NewCops: enable
5
+ SuggestExtensions: false
6
+ Layout/SpaceBeforeBrackets: # (new in 1.7)
7
+ Enabled: true
8
+ Layout/LineLength:
9
+ Max: 350
10
+ Lint/AmbiguousAssignment: # (new in 1.7)
11
+ Enabled: true
12
+ Lint/DeprecatedConstants: # (new in 1.8)
13
+ Enabled: true
14
+ Lint/DuplicateBranch: # (new in 1.3)
15
+ Enabled: true
16
+ Lint/DuplicateRegexpCharacterClassElement: # (new in 1.1)
17
+ Enabled: true
18
+ Lint/EmptyBlock: # (new in 1.1)
19
+ Enabled: true
20
+ Lint/EmptyClass: # (new in 1.3)
21
+ Enabled: true
22
+ Lint/LambdaWithoutLiteralBlock: # (new in 1.8)
23
+ Enabled: true
24
+ Lint/NoReturnInBeginEndBlocks: # (new in 1.2)
25
+ Enabled: true
26
+ Lint/NumberedParameterAssignment: # (new in 1.9)
27
+ Enabled: true
28
+ Lint/OrAssignmentToConstant: # (new in 1.9)
29
+ Enabled: true
30
+ Lint/RedundantDirGlobSort: # (new in 1.8)
31
+ Enabled: true
32
+ Lint/SymbolConversion: # (new in 1.9)
33
+ Enabled: true
34
+ Lint/ToEnumArguments: # (new in 1.1)
35
+ Enabled: true
36
+ Lint/TripleQuotes: # (new in 1.9)
37
+ Enabled: true
38
+ Lint/UnexpectedBlockArity: # (new in 1.5)
39
+ Enabled: true
40
+ Lint/UnmodifiedReduceAccumulator: # (new in 1.1)
41
+ Enabled: true
42
+ Style/ArgumentsForwarding: # (new in 1.1)
43
+ Enabled: true
44
+ Style/CollectionCompact: # (new in 1.2)
45
+ Enabled: true
46
+ Style/DocumentDynamicEvalDefinition: # (new in 1.1)
47
+ Enabled: true
48
+ Style/Documentation:
49
+ Enabled: false
50
+ Style/FrozenStringLiteralComment:
51
+ Enabled: false
52
+ Style/EndlessMethod: # (new in 1.8)
53
+ Enabled: true
54
+ Style/HashConversion: # (new in 1.10)
55
+ Enabled: true
56
+ Style/HashExcept: # (new in 1.7)
57
+ Enabled: true
58
+ Style/IfWithBooleanLiteralBranches: # (new in 1.9)
59
+ Enabled: true
60
+ Style/NegatedIfElseCondition: # (new in 1.2)
61
+ Enabled: true
62
+ Style/NilLambda: # (new in 1.3)
63
+ Enabled: true
64
+ Style/RedundantArgument: # (new in 1.4)
65
+ Enabled: true
66
+ Style/SwapValues: # (new in 1.1)
67
+ Enabled: true
68
+ Rails/ActiveRecordCallbacksOrder: # (new in 2.7)
69
+ Enabled: true
70
+ Rails/AfterCommitOverride: # (new in 2.8)
71
+ Enabled: true
72
+ Rails/AttributeDefaultBlockValue: # (new in 2.9)
73
+ Enabled: true
74
+ Rails/FindById: # (new in 2.7)
75
+ Enabled: true
76
+ Rails/Inquiry: # (new in 2.7)
77
+ Enabled: true
78
+ Rails/MailerName: # (new in 2.7)
79
+ Enabled: true
80
+ Rails/MatchRoute: # (new in 2.7)
81
+ Enabled: true
82
+ Rails/NegateInclude: # (new in 2.7)
83
+ Enabled: true
84
+ Rails/Pluck: # (new in 2.7)
85
+ Enabled: true
86
+ Rails/PluckInWhere: # (new in 2.7)
87
+ Enabled: true
88
+ Rails/RenderInline: # (new in 2.7)
89
+ Enabled: true
90
+ Rails/RenderPlainText: # (new in 2.7)
91
+ Enabled: true
92
+ Rails/ShortI18n: # (new in 2.7)
93
+ Enabled: true
94
+ Rails/SquishedSQLHeredocs: # (new in 2.8)
95
+ Enabled: true
96
+ Rails/UniqueValidationWithoutIndex:
97
+ Enabled: false
98
+ Rails/WhereEquals: # (new in 2.9)
99
+ Enabled: true
100
+ Rails/WhereExists: # (new in 2.7)
101
+ Enabled: true
102
+ Rails/WhereNot: # (new in 2.8)
103
+ Enabled: true
104
+ Metrics/BlockLength:
105
+ Enabled: false
106
+ Metrics/AbcSize:
107
+ Enabled: false
108
+ Metrics/MethodLength:
109
+ Enabled: false
110
+ Metrics/CyclomaticComplexity:
111
+ Max: 15
112
+ Metrics/PerceivedComplexity:
113
+ Max: 15
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-12-01
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at broosk.edogawa@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rabbit_carrots.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,81 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rabbit_carrots (0.1.12)
5
+ activesupport (>= 6.0.0)
6
+ bunny (>= 2.19.0)
7
+ connection_pool (~> 2.3.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (7.0.4)
13
+ concurrent-ruby (~> 1.0, >= 1.0.2)
14
+ i18n (>= 1.6, < 2)
15
+ minitest (>= 5.1)
16
+ tzinfo (~> 2.0)
17
+ amq-protocol (2.3.2)
18
+ ast (2.4.2)
19
+ bunny (2.19.0)
20
+ amq-protocol (~> 2.3, >= 2.3.1)
21
+ sorted_set (~> 1, >= 1.0.2)
22
+ concurrent-ruby (1.1.10)
23
+ connection_pool (2.3.0)
24
+ diff-lcs (1.5.0)
25
+ i18n (1.12.0)
26
+ concurrent-ruby (~> 1.0)
27
+ json (2.6.2)
28
+ minitest (5.16.3)
29
+ parallel (1.22.1)
30
+ parser (3.1.2.1)
31
+ ast (~> 2.4.1)
32
+ rainbow (3.1.1)
33
+ rake (13.0.6)
34
+ rbtree (0.4.5)
35
+ regexp_parser (2.6.1)
36
+ rexml (3.2.5)
37
+ rspec (3.12.0)
38
+ rspec-core (~> 3.12.0)
39
+ rspec-expectations (~> 3.12.0)
40
+ rspec-mocks (~> 3.12.0)
41
+ rspec-core (3.12.0)
42
+ rspec-support (~> 3.12.0)
43
+ rspec-expectations (3.12.0)
44
+ diff-lcs (>= 1.2.0, < 2.0)
45
+ rspec-support (~> 3.12.0)
46
+ rspec-mocks (3.12.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.12.0)
49
+ rspec-support (3.12.0)
50
+ rubocop (1.39.0)
51
+ json (~> 2.3)
52
+ parallel (~> 1.10)
53
+ parser (>= 3.1.2.1)
54
+ rainbow (>= 2.2.2, < 4.0)
55
+ regexp_parser (>= 1.8, < 3.0)
56
+ rexml (>= 3.2.5, < 4.0)
57
+ rubocop-ast (>= 1.23.0, < 2.0)
58
+ 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
+ ruby-progressbar (1.11.0)
63
+ set (1.0.3)
64
+ sorted_set (1.0.3)
65
+ rbtree
66
+ set (~> 1.0)
67
+ tzinfo (2.0.5)
68
+ concurrent-ruby (~> 1.0)
69
+ unicode-display_width (2.3.0)
70
+
71
+ PLATFORMS
72
+ x86_64-linux
73
+
74
+ DEPENDENCIES
75
+ rabbit_carrots!
76
+ rake (~> 13.0)
77
+ rspec (~> 3.0)
78
+ rubocop (~> 1.21)
79
+
80
+ BUNDLED WITH
81
+ 2.3.23
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Brusk Awat
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,64 @@
1
+ # RabbitCarrots
2
+
3
+ RabbitCarrots is a simple background task based on rake to handle the consumption of RabbitMQ message in Rails applications. It is an opinionated library that solves the consumption of messages among microservices, given the following conditions:
4
+
5
+ 1. RabbitMQ is used as an event bus for communication.
6
+ 2. Messages are routed using a single exchange, multiple routing keys.
7
+ 3. One routing key or more can be bound to a single queue.
8
+ 4. The app is a built with Ruby on Rails.
9
+
10
+ ### Considerations
11
+
12
+ The gem adds a rake task to the project using the Railtie framework of Rails. Therefore, the task should be run as a separate process that is independent from the application server.
13
+
14
+ ## Installation
15
+
16
+ Install the gem and add to the application's Gemfile by executing:
17
+
18
+ $ bundle add rabbit_carrots
19
+
20
+ If bundler is not being used to manage dependencies, install the gem by executing:
21
+
22
+ $ gem install rabbit_carrots
23
+
24
+ ## Usage
25
+
26
+ Add the following to ```config/initializers/rabbit_carrots.rb```:
27
+
28
+ ```ruby
29
+ RabbitCarrots.configure do |c|
30
+ c.rabbitmq_host = ENV.fetch('RABBITMQ__HOST', nil)
31
+ c.rabbitmq_port = ENV.fetch('RABBITMQ__PORT', nil)
32
+ c.rabbitmq_user = ENV.fetch('RABBITMQ__USER', nil)
33
+ c.rabbitmq_password = ENV.fetch('RABBITMQ__PASSWORD', nil)
34
+ c.rabbitmq_vhost = ENV.fetch('RABBITMQ__VHOST', nil)
35
+ c.event_bus_exchange_name = ENV.fetch('EVENTBUS__EXCHANGE_NAME', nil)
36
+ c.routing_key_mappings = [
37
+ { routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' },
38
+ { routing_keys: ['RK1', 'RK2'], queue: 'QUEUE_NAME', handler: 'CLASS HANDLER IN STRING' }
39
+ ]
40
+ end
41
+
42
+ ```
43
+
44
+
45
+
46
+ Then run ```bundle exec rake rabbit_carrots:eat```.
47
+
48
+ ## Development
49
+
50
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
51
+
52
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
53
+
54
+ ## Contributing
55
+
56
+ Bug reports and pull requests are welcome on GitHub at https://github.com/ditkrg/rabbit_carrots. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/rabbit_carrots/blob/master/CODE_OF_CONDUCT.md).
57
+
58
+ ## License
59
+
60
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
61
+
62
+ ## Code of Conduct
63
+
64
+ Everyone interacting in the RabbitCarrots project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/rabbit_carrots/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,14 @@
1
+ module RabbitCarrots
2
+ class << self
3
+ attr_accessor :configuration
4
+ end
5
+
6
+ def self.configure
7
+ self.configuration ||= Configuration.new
8
+ yield(configuration)
9
+ end
10
+
11
+ class Configuration
12
+ attr_accessor :rabbitmq_host, :rabbitmq_port, :rabbitmq_user, :rabbitmq_password, :rabbitmq_vhost, :routing_key_mappings, :event_bus_exchange_name
13
+ end
14
+ end
@@ -0,0 +1,26 @@
1
+ require 'singleton'
2
+
3
+ module RabbitCarrots
4
+ class Connection
5
+ include ::Singleton
6
+ attr_reader :connection
7
+
8
+ def initialize
9
+ @connection = Bunny.new(
10
+ host: RabbitCarrots.configuration.rabbitmq_host,
11
+ port: RabbitCarrots.configuration.rabbitmq_port,
12
+ user: RabbitCarrots.configuration.rabbitmq_user,
13
+ password: RabbitCarrots.configuration.rabbitmq_password,
14
+ vhost: RabbitCarrots.configuration.rabbitmq_vhost
15
+ )
16
+
17
+ @connection.start
18
+ end
19
+
20
+ def channel
21
+ @channel ||= ConnectionPool.new do
22
+ connection.create_channel
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ # lib/railtie.rb
2
+ require 'rabbit_carrots'
3
+
4
+ module RabbitCarrots
5
+ class Railtie < Rails::Railtie
6
+ railtie_name :rabbit_carrots
7
+
8
+ rake_tasks do
9
+ path = File.expand_path(__dir__)
10
+ Dir.glob("#{path}/tasks/**/*.rake").each { |f| load f }
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,57 @@
1
+ require 'bunny'
2
+
3
+ namespace :rabbit_carrots do
4
+ desc 'Listener for Queue'
5
+ task eat: :environment do
6
+ Rails.application.eager_load!
7
+
8
+ channels = RabbitCarrots.configuration.routing_key_mappings.map do |mapping|
9
+ # This will be supplied in initializer. At that time, the Handler will not be available to be loaded and will throw Uninitialized Constant
10
+ { **mapping, handler: mapping[:handler].constantize }
11
+ end
12
+
13
+ Rails.logger = Logger.new($stdout)
14
+
15
+ # Run RMQ Subscriber for each channel
16
+ channels.each do |channel|
17
+ handler_class = channel[:handler]
18
+
19
+ raise "#{handler_class.name} must respond to `handle!`" unless handler_class.respond_to?(:handle!)
20
+
21
+ run_task(queue_name: channel[:queue], handler_class:, routing_keys: channel[:routing_keys])
22
+ end
23
+
24
+ # Infinite loop to keep the process running
25
+ loop do
26
+ sleep 1
27
+ end
28
+ end
29
+ end
30
+
31
+ def run_task(queue_name:, handler_class:, routing_keys:)
32
+ RabbitCarrots::Connection.instance.channel.with do |channel|
33
+ exchange = channel.topic(RabbitCarrots.configuration.event_bus_exchange_name, durable: true)
34
+
35
+ Rails.logger.info "Listening on QUEUE: #{queue_name} for ROUTING KEYS: #{routing_keys}"
36
+ queue = channel.queue(queue_name, durable: true)
37
+
38
+ routing_keys.map(&:strip).each { |k| queue.bind(exchange, routing_key: k) }
39
+
40
+ queue.subscribe(block: false, manual_ack: true, prefetch: 10) do |delivery_info, properties, payload|
41
+ Rails.logger.info "Received from queue: #{queue_name}, Routing Keys: #{routing_keys}"
42
+ handler_class.handle!(channel, delivery_info, properties, payload)
43
+ channel.ack(delivery_info.delivery_tag, false)
44
+ rescue EventHandlers::Errors::NackMessage, JSON::ParserError => _e
45
+ Rails.logger.info "Nacked message: #{payload}"
46
+ channel.nack(delivery_info.delivery_tag, false, false)
47
+ rescue EventHandlers::Errors::NackAndRequeueMessage => _e
48
+ Rails.logger.info "Nacked and Requeued message: #{payload}"
49
+ channel.nack(delivery_info.delivery_tag, false, true)
50
+ rescue StandardError => e
51
+ Rails.logger.error "Error handling message: #{payload}. Error: #{e.message}"
52
+ channel.nack(delivery_info.delivery_tag, false, true)
53
+ end
54
+
55
+ Rails.logger.info 'RUN TASK ENDED'
56
+ end
57
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RabbitCarrots
4
+ VERSION = "0.1.12"
5
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rabbit_carrots/version"
4
+ require 'rabbit_carrots/connection'
5
+ require 'rabbit_carrots/configuration'
6
+ require 'rabbit_carrots/railtie' if defined?(Rails)
7
+
8
+
9
+ module RabbitCarrots
10
+ class Error < StandardError; end
11
+ # Your code goes here...
12
+ end
@@ -0,0 +1,4 @@
1
+ module RabbitCarrots
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rabbit_carrots
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.12
5
+ platform: ruby
6
+ authors:
7
+ - Brusk Awat
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bunny
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 2.19.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 2.19.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: connection_pool
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 2.3.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 2.3.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 6.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 6.0.0
55
+ description: A background task based on rake to consume RabbitMQ messages
56
+ email:
57
+ - broosk.edogawa@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".rspec"
63
+ - ".rubocop.yml"
64
+ - CHANGELOG.md
65
+ - CODE_OF_CONDUCT.md
66
+ - Gemfile
67
+ - Gemfile.lock
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - lib/rabbit_carrots.rb
72
+ - lib/rabbit_carrots/configuration.rb
73
+ - lib/rabbit_carrots/connection.rb
74
+ - lib/rabbit_carrots/railtie.rb
75
+ - lib/rabbit_carrots/tasks/rmq.rake
76
+ - lib/rabbit_carrots/version.rb
77
+ - sig/rabbit_carrots.rbs
78
+ homepage: https://github.com/ditkrg
79
+ licenses:
80
+ - MIT
81
+ metadata:
82
+ allowed_push_host: https://rubygems.org
83
+ homepage_uri: https://github.com/ditkrg
84
+ source_code_uri: https://github.com/ditkrg/rabbit_carrots
85
+ changelog_uri: https://github.com/ditkrg/rabbit_carrots
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 3.1.0
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubygems_version: 3.3.7
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: A simple RabbitMQ consumer task
105
+ test_files: []