From 311ea239334492073f048b5ae5ce8a33b99aaa92 Mon Sep 17 00:00:00 2001 From: Pavel Tuma Date: Fri, 26 Jul 2019 15:11:40 +0200 Subject: [PATCH 01/15] Add configuration options for consumer subscribing to queue --- examples/benchmark_worker.rb | 2 +- examples/max_retry_handler.rb | 2 +- examples/profiling_worker.rb | 2 +- examples/workflow_worker.rb | 2 +- lib/sneakers/configuration.rb | 11 +++++- lib/sneakers/queue.rb | 2 +- lib/sneakers/worker.rb | 2 +- spec/sneakers/publisher_spec.rb | 4 +- spec/sneakers/queue_spec.rb | 5 ++- spec/sneakers/worker_handlers_spec.rb | 5 ++- spec/sneakers/worker_spec.rb | 56 +++++++++++++++++++++------ 11 files changed, 70 insertions(+), 23 deletions(-) diff --git a/examples/benchmark_worker.rb b/examples/benchmark_worker.rb index d1866e3c..4f38c300 100644 --- a/examples/benchmark_worker.rb +++ b/examples/benchmark_worker.rb @@ -6,7 +6,7 @@ class BenchmarkWorker from_queue 'downloads', exchange_options: { durable: false }, queue_options: { durable: false }, - :ack => true, + consumer_options: { manual_ack: true }, :threads => 50, :prefetch => 50, :timeout_job_after => 1, diff --git a/examples/max_retry_handler.rb b/examples/max_retry_handler.rb index 4571418f..e407a6d9 100644 --- a/examples/max_retry_handler.rb +++ b/examples/max_retry_handler.rb @@ -15,7 +15,7 @@ Sneakers.logger.level = Logger::DEBUG WORKER_OPTIONS = { - :ack => true, + :consumer_options => { :manual_ack => true }, :threads => 1, :prefetch => 1, :timeout_job_after => 60, diff --git a/examples/profiling_worker.rb b/examples/profiling_worker.rb index 1aab0abc..3abb4fc2 100644 --- a/examples/profiling_worker.rb +++ b/examples/profiling_worker.rb @@ -28,7 +28,7 @@ class ProfilingWorker include Sneakers::Worker from_queue 'downloads', - :ack => true, + :consumer_options => { :manual_ack => true }, :threads => 50, :prefetch => 50, :timeout_job_after => 1, diff --git a/examples/workflow_worker.rb b/examples/workflow_worker.rb index 0739aed1..0d1a5c6f 100644 --- a/examples/workflow_worker.rb +++ b/examples/workflow_worker.rb @@ -6,7 +6,7 @@ class WorkflowWorker from_queue 'downloads', exchange_options: { durable: false }, queue_options: { durable: false }, - :ack => true, + consumer_options: { manual_ack: true }, :threads => 50, :prefetch => 50, :timeout_job_after => 1, diff --git a/lib/sneakers/configuration.rb b/lib/sneakers/configuration.rb index 40ebedfc..5392db6f 100644 --- a/lib/sneakers/configuration.rb +++ b/lib/sneakers/configuration.rb @@ -21,6 +21,12 @@ class Configuration :arguments => {} }.freeze + CONSUMER_OPTION_DEFAULTS = { + :block => false, + :manual_ack => true, + :arguments => {} + }.freeze + DEFAULTS = { # Set up default handler which just logs the error. # Remove this in production if you don't want sensitive data logged. @@ -40,12 +46,12 @@ class Configuration :prefetch => 10, :threads => 10, :share_threads => false, - :ack => true, :heartbeat => 30, :hooks => {}, :exchange => 'sneakers', :exchange_options => EXCHANGE_OPTION_DEFAULTS, - :queue_options => QUEUE_OPTION_DEFAULTS + :queue_options => QUEUE_OPTION_DEFAULTS, + :consumer_options => CONSUMER_OPTION_DEFAULTS }.freeze @@ -107,6 +113,7 @@ def map_all_deprecated_options(hash) hash = map_deprecated_options_key(:exchange_options, :durable, :durable, false, hash) hash = map_deprecated_options_key(:queue_options, :durable, :durable, true, hash) hash = map_deprecated_options_key(:queue_options, :arguments, :arguments, true, hash) + hash = map_deprecated_options_key(:consumer_options, :ack, :manual_ack, true, hash) hash end diff --git a/lib/sneakers/queue.rb b/lib/sneakers/queue.rb index 0bd3a5b7..8e84e217 100644 --- a/lib/sneakers/queue.rb +++ b/lib/sneakers/queue.rb @@ -55,7 +55,7 @@ def subscribe(worker) # retry queues, etc). handler = handler_klass.new(@channel, queue, worker.opts) - @consumer = queue.subscribe(block: false, manual_ack: @opts[:ack]) do | delivery_info, metadata, msg | + @consumer = queue.subscribe(@opts[:consumer_options]) do | delivery_info, metadata, msg | worker.do_work(delivery_info, metadata, msg, handler) end nil diff --git a/lib/sneakers/worker.rb b/lib/sneakers/worker.rb index 53df6ce2..b94a9f40 100644 --- a/lib/sneakers/worker.rb +++ b/lib/sneakers/worker.rb @@ -16,7 +16,7 @@ def initialize(queue = nil, pool = nil, opts = {}) queue_name = self.class.queue_name opts = Sneakers::CONFIG.merge(opts) - @should_ack = opts[:ack] + @should_ack = opts[:consumer_options][:manual_ack] @pool = pool || Concurrent::FixedThreadPool.new(opts[:threads] || Sneakers::Configuration::DEFAULTS[:threads]) @call_with_params = respond_to?(:work_with_params) @content_type = opts[:content_type] diff --git a/spec/sneakers/publisher_spec.rb b/spec/sneakers/publisher_spec.rb index fd7f79b3..ede79030 100644 --- a/spec/sneakers/publisher_spec.rb +++ b/spec/sneakers/publisher_spec.rb @@ -7,7 +7,9 @@ { :prefetch => 25, :durable => true, - :ack => true, + :consumer_options => { + :manual_ack => true + }, :heartbeat => 2, :vhost => '/', :exchange => "sneakers", diff --git a/spec/sneakers/queue_spec.rb b/spec/sneakers/queue_spec.rb index fe203f4f..421d60b4 100644 --- a/spec/sneakers/queue_spec.rb +++ b/spec/sneakers/queue_spec.rb @@ -5,7 +5,6 @@ let :queue_vars do { :prefetch => 25, - :ack => true, :heartbeat => 2, :vhost => '/', :exchange => "sneakers", @@ -16,6 +15,10 @@ }, queue_options: { durable: true + }, + :consumer_options => { + :block => false, + :manual_ack => true } } end diff --git a/spec/sneakers/worker_handlers_spec.rb b/spec/sneakers/worker_handlers_spec.rb index 7d3f15a7..495c49d0 100644 --- a/spec/sneakers/worker_handlers_spec.rb +++ b/spec/sneakers/worker_handlers_spec.rb @@ -11,7 +11,10 @@ class HandlerTestWorker include Sneakers::Worker from_queue 'defaults', - :ack => true + :consumer_options => { + :manual_ack => true + } + def work(msg) if msg.is_a?(StandardError) diff --git a/spec/sneakers/worker_spec.rb b/spec/sneakers/worker_spec.rb index 0217fa7a..1d821e7c 100644 --- a/spec/sneakers/worker_spec.rb +++ b/spec/sneakers/worker_spec.rb @@ -17,7 +17,9 @@ class DummyWorker :exclusive => true, :arguments => { 'x-arg' => 'value' } }, - :ack => false, + :consumer_options => { + :manual_ack => false + }, :threads => 50, :prefetch => 40, :exchange => 'dummy', @@ -38,7 +40,9 @@ def work(msg) class AcksWorker include Sneakers::Worker from_queue 'defaults', - :ack => true + :consumer_options => { + :manual_ack => true + } def work(msg) if msg == :ack @@ -56,7 +60,9 @@ def work(msg) class PublishingWorker include Sneakers::Worker from_queue 'defaults', - :ack => false, + :consumer_options => { + :manual_ack => false + }, :exchange => 'foochange' def work(msg) @@ -67,7 +73,9 @@ def work(msg) class JSONPublishingWorker include Sneakers::Worker from_queue 'defaults', - :ack => false, + :consumer_options => { + :manual_ack => false + }, :exchange => 'foochange' def work(msg) @@ -78,7 +86,9 @@ def work(msg) class LoggingWorker include Sneakers::Worker from_queue 'defaults', - :ack => false + :consumer_options => { + :manual_ack => false + } def work(msg) logger.info "hello" @@ -88,7 +98,9 @@ def work(msg) class JSONWorker include Sneakers::Worker from_queue 'defaults', - :ack => false, + :consumer_options => { + :manual_ack => false + }, :content_type => 'application/json' def work(msg) @@ -98,7 +110,10 @@ def work(msg) class MetricsWorker include Sneakers::Worker from_queue 'defaults', - :ack => true + :consumer_options => { + :manual_ack => true + } + def work(msg) metrics.increment "foobar" @@ -109,7 +124,9 @@ def work(msg) class WithParamsWorker include Sneakers::Worker from_queue 'defaults', - :ack => true + :consumer_options => { + :manual_ack => true + } def work_with_params(msg, delivery_info, metadata) msg @@ -176,7 +193,6 @@ def work(msg) :prefetch => 10, :threads => 10, :share_threads => false, - :ack => true, :amqp => "amqp://guest:guest@localhost:5672", :vhost => "/", :exchange => "sneakers", @@ -192,6 +208,11 @@ def work(msg) :exclusive => false, :arguments => {} }, + :consumer_options => { + :block => false, + :manual_ack => true, + :arguments => {} + }, :hooks => {}, :handler => Sneakers::Handlers::Oneshot, :heartbeat => 30, @@ -214,7 +235,6 @@ def work(msg) :prefetch => 40, :threads => 50, :share_threads => false, - :ack => false, :amqp => "amqp://guest:guest@localhost:5672", :vhost => "/", :exchange => "dummy", @@ -230,6 +250,11 @@ def work(msg) :exclusive => true, :arguments => { 'x-arg' => 'value' } }, + :consumer_options => { + :block => false, + :manual_ack => false, + :arguments => {} + }, :hooks => {}, :handler => Sneakers::Handlers::Oneshot, :heartbeat => 5, @@ -252,7 +277,6 @@ def work(msg) :prefetch => 10, :threads => 10, :share_threads => false, - :ack => true, :amqp => "amqp://guest:guest@localhost:5672", :vhost => "/", :exchange => "sneakers", @@ -268,6 +292,11 @@ def work(msg) :exclusive => false, :arguments => { 'x-arg2' => 'value2' } }, + :consumer_options => { + :block => false, + :manual_ack => true, + :arguments => {} + }, :hooks => {}, :handler => Sneakers::Handlers::Oneshot, :heartbeat => 30, @@ -408,7 +437,10 @@ def call(deserialized_msg, delivery_info, metadata, handler) let(:worker) do Class.new do include Sneakers::Worker - from_queue 'defaults', ack: false + from_queue 'defaults', + :consumer_options => { + :manual_ack => false + } def work_with_params(msg, delivery_info, metadata) msg From 743e6c9eca37a12f8d7124f31c89c3a2e8a04473 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Wed, 14 Aug 2019 21:24:04 +1000 Subject: [PATCH 02/15] Closes #400 --- lib/sneakers/runner.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sneakers/runner.rb b/lib/sneakers/runner.rb index b681baa2..caaa102a 100644 --- a/lib/sneakers/runner.rb +++ b/lib/sneakers/runner.rb @@ -40,7 +40,7 @@ def to_h def reload_config! - Sneakers.logger.warn("Loading runner configuration...") + Sneakers.logger.info("Loading runner configuration...") config_file = Sneakers::CONFIG[:runner_config_file] if config_file From ce2e015de8b1c856297f040e2e603d42c4f71c2b Mon Sep 17 00:00:00 2001 From: Gabriel Chaney Date: Mon, 23 Dec 2019 22:32:53 -0700 Subject: [PATCH 03/15] Bump to 2.12.0 for release --- lib/sneakers/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sneakers/version.rb b/lib/sneakers/version.rb index 5304ed17..5d22ad0c 100644 --- a/lib/sneakers/version.rb +++ b/lib/sneakers/version.rb @@ -1,3 +1,3 @@ module Sneakers - VERSION = "2.12.0.pre" + VERSION = "2.12.0" end From ea446c0570a803b01999f26602fd1a75d62ced94 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 9 Jan 2020 00:15:11 +0300 Subject: [PATCH 04/15] Bump version to development --- lib/sneakers/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sneakers/version.rb b/lib/sneakers/version.rb index 5d22ad0c..c69fef9a 100644 --- a/lib/sneakers/version.rb +++ b/lib/sneakers/version.rb @@ -1,3 +1,3 @@ module Sneakers - VERSION = "2.12.0" + VERSION = "2.13.0.pre" end From ff4a4c3b0398b6e6b3d5fc006f8fa6732f424369 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Thu, 9 Jan 2020 00:19:56 +0300 Subject: [PATCH 05/15] Allow for Rake 13.x, closes #422 --- Gemfile | 2 ++ sneakers.gemspec | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 4406e4a4..9f96a26d 100644 --- a/Gemfile +++ b/Gemfile @@ -2,4 +2,6 @@ source 'https://rubygems.org' gem 'ruby-prof', platforms: [:ruby_22, :ruby_23, :ruby_24] +gem 'rake', '>= 12.3', '< 14.0' + gemspec diff --git a/sneakers.gemspec b/sneakers.gemspec index 9e29a2e5..2615d6dd 100755 --- a/sneakers.gemspec +++ b/sneakers.gemspec @@ -27,7 +27,7 @@ Gem::Specification.new do |gem| gem.add_dependency 'bunny', '~> 2.14' gem.add_dependency 'concurrent-ruby', '~> 1.0' gem.add_dependency 'thor' - gem.add_dependency 'rake', '~> 12.3' + gem.add_dependency 'rake', '>= 12.3', '< 14.0' # for integration environment (see .travis.yml and integration_spec) gem.add_development_dependency 'rabbitmq_http_api_client' From 454fc9ffda42d1cd7e96be2002522363e54476a3 Mon Sep 17 00:00:00 2001 From: Rafael Souza Date: Thu, 12 Dec 2019 17:21:40 -0500 Subject: [PATCH 06/15] Use ERB in yaml in order to use env vars to control worker count/etc --- lib/sneakers/spawner.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/sneakers/spawner.rb b/lib/sneakers/spawner.rb index 54b04b1f..051148ae 100644 --- a/lib/sneakers/spawner.rb +++ b/lib/sneakers/spawner.rb @@ -1,4 +1,5 @@ require 'yaml' +require 'erb' module Sneakers class Spawner @@ -12,10 +13,11 @@ def self.spawn end @pids = [] @exec_string = "bundle exec rake sneakers:run" - worker_config = YAML.load(File.read(worker_group_config_file)) + worker_config = YAML.load(ERB.new(File.read(worker_group_config_file)).result) worker_config.keys.each do |group_name| workers = worker_config[group_name]['classes'] workers = workers.join "," if workers.is_a?(Array) + p "WORKER COUNT = #{worker_config[group_name]["workers"].to_s}" @pids << fork do @exec_hash = {"WORKERS"=> workers, "WORKER_COUNT" => worker_config[group_name]["workers"].to_s} Kernel.exec(@exec_hash, @exec_string) From 63cec027bb2aa432def8f45fd3847d6b61a47035 Mon Sep 17 00:00:00 2001 From: rsouza-mdlive Date: Wed, 18 Dec 2019 21:14:33 -0500 Subject: [PATCH 07/15] remove comment --- lib/sneakers/spawner.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/sneakers/spawner.rb b/lib/sneakers/spawner.rb index 051148ae..25fb4e16 100644 --- a/lib/sneakers/spawner.rb +++ b/lib/sneakers/spawner.rb @@ -17,7 +17,6 @@ def self.spawn worker_config.keys.each do |group_name| workers = worker_config[group_name]['classes'] workers = workers.join "," if workers.is_a?(Array) - p "WORKER COUNT = #{worker_config[group_name]["workers"].to_s}" @pids << fork do @exec_hash = {"WORKERS"=> workers, "WORKER_COUNT" => worker_config[group_name]["workers"].to_s} Kernel.exec(@exec_hash, @exec_string) From e1a9c8afc05d927c0d5d2aa37a2dfc6829ac2b4d Mon Sep 17 00:00:00 2001 From: Vladimir Temnikov Date: Thu, 17 Oct 2019 12:50:08 +0300 Subject: [PATCH 08/15] Zeitwerk mode --- lib/sneakers/tasks.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/sneakers/tasks.rb b/lib/sneakers/tasks.rb index 689aa3e6..c1b96f9c 100644 --- a/lib/sneakers/tasks.rb +++ b/lib/sneakers/tasks.rb @@ -10,7 +10,11 @@ Rake::Task['environment'].invoke if defined?(::Rails) - ::Rails.application.eager_load! + if defined?(::Zeitwerk) + ::Zeitwerk::Loader.eager_load_all + else + ::Rails.application.eager_load! + end end if ENV["WORKERS"].nil? From 282543d38b8dae1b3cbdfe74437dba9a6f1d5223 Mon Sep 17 00:00:00 2001 From: "ron.klein" Date: Wed, 2 Oct 2019 07:55:25 +0300 Subject: [PATCH 09/15] provide the mandatory argument needed to delegate the stop call to inner service engine --- lib/sneakers/runner.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/sneakers/runner.rb b/lib/sneakers/runner.rb index caaa102a..37f674f1 100644 --- a/lib/sneakers/runner.rb +++ b/lib/sneakers/runner.rb @@ -12,8 +12,8 @@ def run @se.run end - def stop - @se.stop + def stop(stop_graceful=true) + @se.stop(stop_graceful) end end From a726886da11d45ec9cf361e6f245bd272444427a Mon Sep 17 00:00:00 2001 From: Jason Lombardozzi Date: Thu, 14 Nov 2019 09:11:50 -0500 Subject: [PATCH 10/15] Update example middleware worker Addition to fix #417 Update DemoMiddleware to return worker result for property handling --- examples/middleware_worker.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/examples/middleware_worker.rb b/examples/middleware_worker.rb index e1ccf0b4..685fb2a2 100644 --- a/examples/middleware_worker.rb +++ b/examples/middleware_worker.rb @@ -21,8 +21,10 @@ def initialize(app, *args) def call(deserialized_msg, delivery_info, metadata, handler) puts "******** DemoMiddleware - before; args #{@args}" - @app.call(deserialized_msg, delivery_info, metadata, handler) + res = @app.call(deserialized_msg, delivery_info, metadata, handler) puts "******** DemoMiddleware - after" + + res end end From d8c3790867938cf7120ab979528b9b3958830117 Mon Sep 17 00:00:00 2001 From: Ruslan Khaertdinov Date: Mon, 26 Aug 2019 12:27:03 +0300 Subject: [PATCH 11/15] Remove extra blank line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 1ebb7b80..1543d9e8 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,6 @@ class Processor include Sneakers::Worker from_queue :logs - def work(msg) err = JSON.parse(msg) if err["type"] == "error" From 81d89dc45596c79bc5ef7855c9265efc5fa75afa Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 31 Mar 2020 11:49:19 +0200 Subject: [PATCH 12/15] Remove rake development dependency We already have it as runtime dependency --- sneakers.gemspec | 1 - 1 file changed, 1 deletion(-) diff --git a/sneakers.gemspec b/sneakers.gemspec index 2615d6dd..8018d2c5 100755 --- a/sneakers.gemspec +++ b/sneakers.gemspec @@ -33,7 +33,6 @@ Gem::Specification.new do |gem| gem.add_development_dependency 'rabbitmq_http_api_client' gem.add_development_dependency 'redis' - gem.add_development_dependency 'rake', '~> 12.3' gem.add_development_dependency 'minitest', '~> 5.11' gem.add_development_dependency 'rr', '~> 1.2.1' gem.add_development_dependency 'unparser', '0.2.2' # keep below 0.2.5 for ruby 2.0 compat. From 412748f179a5ca47cffb1ebc43d00a905690b553 Mon Sep 17 00:00:00 2001 From: Rustam Sharshenov Date: Mon, 15 Jun 2020 16:14:58 +0100 Subject: [PATCH 13/15] Handle all exceptions except SignalException and SystemExit Previously Sneakers was able to handle StandardError and ScriptError exceptions and their descendants. But there are more exceptions that could cause problems. * SystemStackError (stack level too deep) * NoMemoryError * custom descendants of Exception (e.g. declared by gems) In case of these exceptions, the handler is unable to report job state to the RabbitMQ. RabbitMQ keeps sending new jobs to the Sneakers until prefetch value reached. It makes Sneakers worker hang without processing any new message. --- lib/sneakers/worker.rb | 41 ++++++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/lib/sneakers/worker.rb b/lib/sneakers/worker.rb index b94a9f40..94478299 100644 --- a/lib/sneakers/worker.rb +++ b/lib/sneakers/worker.rb @@ -72,31 +72,34 @@ def process_work(delivery_info, metadata, msg, handler) end res = block_to_call.call(deserialized_msg, delivery_info, metadata, handler) end - rescue StandardError, ScriptError => ex + rescue SignalException, SystemExit + # ServerEngine handles these exceptions, so they are not expected to be raised within the worker. + # Nevertheless, they are listed here to ensure that they are not caught by the rescue block below. + raise + rescue Exception => ex res = :error error = ex worker_error(ex, log_msg: log_msg(msg), class: self.class.name, message: msg, delivery_info: delivery_info, metadata: metadata) - end - - if @should_ack - - if res == :ack - # note to future-self. never acknowledge multiple (multiple=true) messages under threads. - handler.acknowledge(delivery_info, metadata, msg) - elsif res == :error - handler.error(delivery_info, metadata, msg, error) - elsif res == :reject - handler.reject(delivery_info, metadata, msg) - elsif res == :requeue - handler.reject(delivery_info, metadata, msg, true) - else - handler.noop(delivery_info, metadata, msg) + ensure + if @should_ack + if res == :ack + # note to future-self. never acknowledge multiple (multiple=true) messages under threads. + handler.acknowledge(delivery_info, metadata, msg) + elsif res == :error + handler.error(delivery_info, metadata, msg, error) + elsif res == :reject + handler.reject(delivery_info, metadata, msg) + elsif res == :requeue + handler.reject(delivery_info, metadata, msg, true) + else + handler.noop(delivery_info, metadata, msg) + end + metrics.increment("work.#{self.class.name}.handled.#{res || 'noop'}") end - metrics.increment("work.#{self.class.name}.handled.#{res || 'noop'}") - end - metrics.increment("work.#{self.class.name}.ended") + metrics.increment("work.#{self.class.name}.ended") + end end def stop From 225e6e06091392cb2276208479ed554f3891db1f Mon Sep 17 00:00:00 2001 From: Rustam Sharshenov Date: Mon, 15 Jun 2020 16:34:12 +0100 Subject: [PATCH 14/15] Make result code processing code more readable --- lib/sneakers/worker.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/lib/sneakers/worker.rb b/lib/sneakers/worker.rb index 94478299..bfe74095 100644 --- a/lib/sneakers/worker.rb +++ b/lib/sneakers/worker.rb @@ -83,15 +83,12 @@ def process_work(delivery_info, metadata, msg, handler) message: msg, delivery_info: delivery_info, metadata: metadata) ensure if @should_ack - if res == :ack - # note to future-self. never acknowledge multiple (multiple=true) messages under threads. - handler.acknowledge(delivery_info, metadata, msg) - elsif res == :error - handler.error(delivery_info, metadata, msg, error) - elsif res == :reject - handler.reject(delivery_info, metadata, msg) - elsif res == :requeue - handler.reject(delivery_info, metadata, msg, true) + case res + # note to future-self. never acknowledge multiple (multiple=true) messages under threads. + when :ack then handler.acknowledge(delivery_info, metadata, msg) + when :error then handler.error(delivery_info, metadata, msg, error) + when :reject then handler.reject(delivery_info, metadata, msg) + when :requeue then handler.reject(delivery_info, metadata, msg, true) else handler.noop(delivery_info, metadata, msg) end From a1f4b0c8f3100796b656f5045e0253b49909ba22 Mon Sep 17 00:00:00 2001 From: "Dotan J. Nahum" Date: Wed, 20 Jan 2021 17:47:44 +0200 Subject: [PATCH 15/15] Update sneakers.gemspec --- sneakers.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sneakers.gemspec b/sneakers.gemspec index 8018d2c5..c9456cb3 100755 --- a/sneakers.gemspec +++ b/sneakers.gemspec @@ -12,7 +12,7 @@ Gem::Specification.new do |gem| gem.email = ['jondotan@gmail.com'] gem.description = %q( Fast background processing framework for Ruby and RabbitMQ ) gem.summary = %q( Fast background processing framework for Ruby and RabbitMQ ) - gem.homepage = 'http://sneakers.io' + gem.homepage = 'https://github.com/jondot/sneakers' gem.license = 'MIT' gem.required_ruby_version = Gem::Requirement.new(">= 2.2")