shoryuken 6.2.1 → 7.0.0.alpha2
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 +4 -4
 - data/.devcontainer/base.Dockerfile +1 -1
 - data/.github/workflows/push.yml +36 -0
 - data/.github/workflows/specs.yml +40 -30
 - data/.github/workflows/verify-action-pins.yml +16 -0
 - data/.gitignore +2 -1
 - data/.rspec +2 -1
 - data/.rubocop.yml +6 -1
 - data/.ruby-version +1 -0
 - data/Appraisals +8 -27
 - data/CHANGELOG.md +213 -139
 - data/Gemfile +2 -7
 - data/README.md +14 -26
 - data/Rakefile +2 -0
 - data/bin/cli/base.rb +1 -2
 - data/bin/cli/sqs.rb +13 -5
 - data/bin/shoryuken +2 -1
 - data/docker-compose.yml +22 -0
 - data/gemfiles/rails_7_0.gemfile +10 -13
 - data/gemfiles/rails_7_1.gemfile +19 -0
 - data/gemfiles/rails_7_2.gemfile +19 -0
 - data/gemfiles/rails_8_0.gemfile +19 -0
 - data/lib/shoryuken/body_parser.rb +3 -1
 - data/lib/shoryuken/client.rb +2 -0
 - data/lib/shoryuken/default_exception_handler.rb +2 -0
 - data/lib/shoryuken/default_worker_registry.rb +11 -11
 - data/lib/shoryuken/environment_loader.rb +6 -6
 - data/lib/shoryuken/extensions/active_job_adapter.rb +13 -6
 - data/lib/shoryuken/extensions/active_job_concurrent_send_adapter.rb +5 -5
 - data/lib/shoryuken/extensions/active_job_extensions.rb +2 -0
 - data/lib/shoryuken/fetcher.rb +4 -2
 - data/lib/shoryuken/helpers/atomic_boolean.rb +44 -0
 - data/lib/shoryuken/helpers/atomic_counter.rb +104 -0
 - data/lib/shoryuken/helpers/atomic_hash.rb +182 -0
 - data/lib/shoryuken/helpers/hash_utils.rb +56 -0
 - data/lib/shoryuken/helpers/string_utils.rb +65 -0
 - data/lib/shoryuken/inline_message.rb +22 -0
 - data/lib/shoryuken/launcher.rb +2 -0
 - data/lib/shoryuken/logging.rb +19 -5
 - data/lib/shoryuken/manager.rb +15 -5
 - data/lib/shoryuken/message.rb +2 -0
 - data/lib/shoryuken/middleware/chain.rb +2 -0
 - data/lib/shoryuken/middleware/server/active_record.rb +2 -0
 - data/lib/shoryuken/middleware/server/auto_delete.rb +2 -0
 - data/lib/shoryuken/middleware/server/auto_extend_visibility.rb +10 -10
 - data/lib/shoryuken/middleware/server/exponential_backoff_retry.rb +5 -3
 - data/lib/shoryuken/middleware/server/timing.rb +2 -0
 - data/lib/shoryuken/options.rb +14 -5
 - data/lib/shoryuken/polling/base_strategy.rb +126 -0
 - data/lib/shoryuken/polling/queue_configuration.rb +103 -0
 - data/lib/shoryuken/polling/strict_priority.rb +2 -0
 - data/lib/shoryuken/polling/weighted_round_robin.rb +2 -0
 - data/lib/shoryuken/processor.rb +5 -2
 - data/lib/shoryuken/queue.rb +6 -4
 - data/lib/shoryuken/runner.rb +9 -12
 - data/lib/shoryuken/util.rb +6 -6
 - data/lib/shoryuken/version.rb +3 -1
 - data/lib/shoryuken/worker/default_executor.rb +2 -0
 - data/lib/shoryuken/worker/inline_executor.rb +9 -2
 - data/lib/shoryuken/worker.rb +2 -0
 - data/lib/shoryuken/worker_registry.rb +2 -0
 - data/lib/shoryuken.rb +11 -34
 - data/renovate.json +16 -0
 - data/shoryuken.gemspec +7 -4
 - data/spec/integration/launcher_spec.rb +3 -4
 - data/spec/shared_examples_for_active_job.rb +13 -8
 - data/spec/shoryuken/body_parser_spec.rb +2 -4
 - data/spec/shoryuken/client_spec.rb +1 -1
 - data/spec/shoryuken/default_exception_handler_spec.rb +9 -10
 - data/spec/shoryuken/default_worker_registry_spec.rb +1 -2
 - data/spec/shoryuken/environment_loader_spec.rb +9 -8
 - data/spec/shoryuken/extensions/active_job_adapter_spec.rb +2 -1
 - data/spec/shoryuken/extensions/active_job_base_spec.rb +2 -1
 - data/spec/shoryuken/extensions/active_job_concurrent_send_adapter_spec.rb +2 -1
 - data/spec/shoryuken/extensions/active_job_wrapper_spec.rb +2 -1
 - data/spec/shoryuken/fetcher_spec.rb +23 -26
 - data/spec/shoryuken/helpers/atomic_boolean_spec.rb +196 -0
 - data/spec/shoryuken/helpers/atomic_counter_spec.rb +177 -0
 - data/spec/shoryuken/helpers/atomic_hash_spec.rb +307 -0
 - data/spec/shoryuken/helpers/hash_utils_spec.rb +145 -0
 - data/spec/shoryuken/helpers/string_utils_spec.rb +124 -0
 - data/spec/shoryuken/helpers_integration_spec.rb +96 -0
 - data/spec/shoryuken/inline_message_spec.rb +196 -0
 - data/spec/shoryuken/launcher_spec.rb +1 -2
 - data/spec/shoryuken/manager_spec.rb +1 -2
 - data/spec/shoryuken/middleware/chain_spec.rb +1 -1
 - data/spec/shoryuken/middleware/server/auto_delete_spec.rb +1 -1
 - data/spec/shoryuken/middleware/server/auto_extend_visibility_spec.rb +1 -1
 - data/spec/shoryuken/middleware/server/exponential_backoff_retry_spec.rb +1 -1
 - data/spec/shoryuken/middleware/server/timing_spec.rb +1 -1
 - data/spec/shoryuken/options_spec.rb +4 -4
 - data/spec/shoryuken/polling/base_strategy_spec.rb +280 -0
 - data/spec/shoryuken/polling/queue_configuration_spec.rb +195 -0
 - data/spec/shoryuken/polling/strict_priority_spec.rb +1 -1
 - data/spec/shoryuken/polling/weighted_round_robin_spec.rb +1 -1
 - data/spec/shoryuken/processor_spec.rb +1 -1
 - data/spec/shoryuken/queue_spec.rb +2 -3
 - data/spec/shoryuken/runner_spec.rb +1 -3
 - data/spec/shoryuken/util_spec.rb +1 -1
 - data/spec/shoryuken/worker/default_executor_spec.rb +1 -1
 - data/spec/shoryuken/worker/inline_executor_spec.rb +57 -1
 - data/spec/shoryuken/worker_spec.rb +15 -11
 - data/spec/shoryuken_spec.rb +1 -1
 - data/spec/spec_helper.rb +19 -4
 - metadata +79 -35
 - data/.codeclimate.yml +0 -20
 - data/.github/FUNDING.yml +0 -12
 - data/.github/dependabot.yml +0 -6
 - data/.github/workflows/stale.yml +0 -20
 - data/.reek.yml +0 -5
 - data/gemfiles/aws_sdk_core_2.gemfile +0 -21
 - data/gemfiles/rails_4_2.gemfile +0 -20
 - data/gemfiles/rails_5_2.gemfile +0 -21
 - data/gemfiles/rails_6_0.gemfile +0 -21
 - data/gemfiles/rails_6_1.gemfile +0 -21
 - data/lib/shoryuken/core_ext.rb +0 -69
 - data/lib/shoryuken/polling/base.rb +0 -67
 - data/shoryuken.jpg +0 -0
 - data/spec/shoryuken/core_ext_spec.rb +0 -40
 
    
        data/Gemfile
    CHANGED
    
    | 
         @@ -5,19 +5,14 @@ gemspec 
     | 
|
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            group :test do
         
     | 
| 
       7 
7 
     | 
    
         
             
              gem 'activejob'
         
     | 
| 
       8 
     | 
    
         
            -
              gem 'aws-sdk-core', '~> 3'
         
     | 
| 
       9 
     | 
    
         
            -
              # Pin to 1.65.0 because of below issues:
         
     | 
| 
       10 
     | 
    
         
            -
              # - https://github.com/ruby-shoryuken/shoryuken/pull/753#issuecomment-1822720647
         
     | 
| 
       11 
     | 
    
         
            -
              # - https://github.com/getmoto/moto/issues/7054
         
     | 
| 
       12 
     | 
    
         
            -
              gem 'aws-sdk-sqs', '1.65.0'
         
     | 
| 
       13 
     | 
    
         
            -
              gem 'codeclimate-test-reporter', require: nil
         
     | 
| 
       14 
8 
     | 
    
         
             
              gem 'httparty'
         
     | 
| 
       15 
9 
     | 
    
         
             
              gem 'multi_xml'
         
     | 
| 
       16 
10 
     | 
    
         
             
              gem 'simplecov'
         
     | 
| 
      
 11 
     | 
    
         
            +
              gem 'warning'
         
     | 
| 
       17 
12 
     | 
    
         
             
            end
         
     | 
| 
       18 
13 
     | 
    
         | 
| 
       19 
14 
     | 
    
         
             
            group :development do
         
     | 
| 
       20 
15 
     | 
    
         
             
              gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
         
     | 
| 
       21 
16 
     | 
    
         
             
              gem 'pry-byebug'
         
     | 
| 
       22 
     | 
    
         
            -
              gem 'rubocop' 
     | 
| 
      
 17 
     | 
    
         
            +
              gem 'rubocop'
         
     | 
| 
       23 
18 
     | 
    
         
             
            end
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,29 +1,25 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            **I'm looking for Shoryuken maintainers, are you interested on helping to maintain Shoryuken? [Join our Slack](https://join.slack.com/t/shoryuken/shared_invite/zt-19xjq3iqc-KmoJ6eU6~qvZNqcLzIrjww)**
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
1 
     | 
    
         
             
            # Shoryuken
         
     | 
| 
       4 
2 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
            
         
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
3 
     | 
    
         
             
            Shoryuken _sho-ryu-ken_ is a super-efficient [Amazon SQS](https://aws.amazon.com/sqs/) thread-based message processor.
         
     | 
| 
       8 
4 
     | 
    
         | 
| 
       9 
5 
     | 
    
         
             
            [](https://github.com/ruby-shoryuken/shoryuken/actions)
         
     | 
| 
       10 
     | 
    
         
            -
            [](https://slack.shoryuken.io)
         
     | 
| 
       11 
7 
     | 
    
         | 
| 
       12 
8 
     | 
    
         
             
            ## Key features
         
     | 
| 
       13 
9 
     | 
    
         | 
| 
       14 
     | 
    
         
            -
            - [Rails Active Job](https://github.com/ 
     | 
| 
       15 
     | 
    
         
            -
            - [Queue Load balancing](https://github.com/ 
     | 
| 
       16 
     | 
    
         
            -
            - [Concurrency per queue](https://github.com/ 
     | 
| 
       17 
     | 
    
         
            -
            - [Long Polling](https://github.com/ 
     | 
| 
       18 
     | 
    
         
            -
            - [Batch processing](https://github.com/ 
     | 
| 
       19 
     | 
    
         
            -
            - [Auto extend visibility timeout](https://github.com/ 
     | 
| 
       20 
     | 
    
         
            -
            - [Exponential backoff](https://github.com/ 
     | 
| 
       21 
     | 
    
         
            -
            - [Middleware support](https://github.com/ 
     | 
| 
      
 10 
     | 
    
         
            +
            - [Rails Active Job](https://github.com/ruby-shoryuken/shoryuken/wiki/Rails-Integration-Active-Job)
         
     | 
| 
      
 11 
     | 
    
         
            +
            - [Queue Load balancing](https://github.com/ruby-shoryuken/shoryuken/wiki/Shoryuken-options#load-balancing)
         
     | 
| 
      
 12 
     | 
    
         
            +
            - [Concurrency per queue](https://github.com/ruby-shoryuken/shoryuken/wiki/Processing-Groups)
         
     | 
| 
      
 13 
     | 
    
         
            +
            - [Long Polling](https://github.com/ruby-shoryuken/shoryuken/wiki/Long-Polling)
         
     | 
| 
      
 14 
     | 
    
         
            +
            - [Batch processing](https://github.com/ruby-shoryuken/shoryuken/wiki/Worker-options#batch)
         
     | 
| 
      
 15 
     | 
    
         
            +
            - [Auto extend visibility timeout](https://github.com/ruby-shoryuken/shoryuken/wiki/Worker-options#auto_visibility_timeout)
         
     | 
| 
      
 16 
     | 
    
         
            +
            - [Exponential backoff](https://github.com/ruby-shoryuken/shoryuken/wiki/Worker-options#retry_intervals)
         
     | 
| 
      
 17 
     | 
    
         
            +
            - [Middleware support](https://github.com/ruby-shoryuken/shoryuken/wiki/Middleware)
         
     | 
| 
       22 
18 
     | 
    
         
             
            - Amazon SQS CLI. See `shoryuken help sqs`
         
     | 
| 
       23 
19 
     | 
    
         | 
| 
       24 
20 
     | 
    
         
             
            ## Requirements
         
     | 
| 
       25 
21 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            Ruby  
     | 
| 
      
 22 
     | 
    
         
            +
            Ruby 3.0 or greater.
         
     | 
| 
       27 
23 
     | 
    
         | 
| 
       28 
24 
     | 
    
         
             
            ## Installation
         
     | 
| 
       29 
25 
     | 
    
         | 
| 
         @@ -33,14 +29,6 @@ Add this line to your application's Gemfile: 
     | 
|
| 
       33 
29 
     | 
    
         
             
            gem 'shoryuken'
         
     | 
| 
       34 
30 
     | 
    
         
             
            ```
         
     | 
| 
       35 
31 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
            If you are using AWS SDK version 3, please also add this line:
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
            ```ruby
         
     | 
| 
       39 
     | 
    
         
            -
            gem 'aws-sdk-sqs'
         
     | 
| 
       40 
     | 
    
         
            -
            ```
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
            The extra gem `aws-sdk-sqs` is required in order to keep Shoryuken compatible with AWS SDK version 2 and 3.
         
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
32 
     | 
    
         
             
            And then execute:
         
     | 
| 
       45 
33 
     | 
    
         | 
| 
       46 
34 
     | 
    
         
             
            ```shell
         
     | 
| 
         @@ -49,11 +37,11 @@ $ bundle 
     | 
|
| 
       49 
37 
     | 
    
         | 
| 
       50 
38 
     | 
    
         
             
            ## Usage
         
     | 
| 
       51 
39 
     | 
    
         | 
| 
       52 
     | 
    
         
            -
            Check the [Getting Started](https://github.com/ 
     | 
| 
      
 40 
     | 
    
         
            +
            Check the [Getting Started](https://github.com/ruby-shoryuken/shoryuken/wiki/Getting-Started) page.
         
     | 
| 
       53 
41 
     | 
    
         | 
| 
       54 
42 
     | 
    
         
             
            ## More Information
         
     | 
| 
       55 
43 
     | 
    
         | 
| 
       56 
     | 
    
         
            -
            For more information check the [wiki page](https://github.com/ 
     | 
| 
      
 44 
     | 
    
         
            +
            For more information check the [wiki page](https://github.com/ruby-shoryuken/shoryuken/wiki).
         
     | 
| 
       57 
45 
     | 
    
         | 
| 
       58 
46 
     | 
    
         
             
            ## Credits
         
     | 
| 
       59 
47 
     | 
    
         | 
| 
         @@ -61,7 +49,7 @@ For more information check the [wiki page](https://github.com/phstc/shoryuken/wi 
     | 
|
| 
       61 
49 
     | 
    
         | 
| 
       62 
50 
     | 
    
         
             
            ## Contributing
         
     | 
| 
       63 
51 
     | 
    
         | 
| 
       64 
     | 
    
         
            -
            1. Fork it ( https://github.com/ 
     | 
| 
      
 52 
     | 
    
         
            +
            1. Fork it ( https://github.com/ruby-shoryuken/shoryuken/fork )
         
     | 
| 
       65 
53 
     | 
    
         
             
            2. Create your feature branch (`git checkout -b my-new-feature`)
         
     | 
| 
       66 
54 
     | 
    
         
             
            3. Commit your changes (`git commit -am 'Add some feature'`)
         
     | 
| 
       67 
55 
     | 
    
         
             
            4. Push to the branch (`git push origin my-new-feature`)
         
     | 
| 
         @@ -69,7 +57,7 @@ For more information check the [wiki page](https://github.com/phstc/shoryuken/wi 
     | 
|
| 
       69 
57 
     | 
    
         | 
| 
       70 
58 
     | 
    
         
             
            ### Testing
         
     | 
| 
       71 
59 
     | 
    
         | 
| 
       72 
     | 
    
         
            -
            To run all unit specs against the latest dependency  
     | 
| 
      
 60 
     | 
    
         
            +
            To run all unit specs against the latest dependency versions, execute
         
     | 
| 
       73 
61 
     | 
    
         | 
| 
       74 
62 
     | 
    
         
             
            ```sh
         
     | 
| 
       75 
63 
     | 
    
         
             
            bundle exec rake spec
         
     | 
    
        data/Rakefile
    CHANGED
    
    
    
        data/bin/cli/base.rb
    CHANGED
    
    
    
        data/bin/cli/sqs.rb
    CHANGED
    
    | 
         @@ -5,7 +5,7 @@ module Shoryuken 
     | 
|
| 
       5 
5 
     | 
    
         
             
              module CLI
         
     | 
| 
       6 
6 
     | 
    
         
             
                class SQS < Base
         
     | 
| 
       7 
7 
     | 
    
         
             
                  # See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/quotas-messages.html
         
     | 
| 
       8 
     | 
    
         
            -
                  MAX_BATCH_SIZE =  
     | 
| 
      
 8 
     | 
    
         
            +
                  MAX_BATCH_SIZE = 1024 * 1024
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
                  namespace :sqs
         
     | 
| 
       11 
11 
     | 
    
         
             
                  class_option :endpoint, aliases: '-e', type: :string, default: ENV['SHORYUKEN_SQS_ENDPOINT'], desc: 'Endpoint URL'
         
     | 
| 
         @@ -14,10 +14,17 @@ module Shoryuken 
     | 
|
| 
       14 
14 
     | 
    
         
             
                    def normalize_dump_message(message)
         
     | 
| 
       15 
15 
     | 
    
         
             
                      # symbolize_keys is needed for keeping it compatible with `requeue`
         
     | 
| 
       16 
16 
     | 
    
         
             
                      attributes = message[:attributes].symbolize_keys
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                      # See https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_MessageAttributeValue.html
         
     | 
| 
      
 19 
     | 
    
         
            +
                      # The `string_list_values` and `binary_list_values` are not implemented. Reserved for future use.
         
     | 
| 
      
 20 
     | 
    
         
            +
                      message_attributes = message[:message_attributes].each_with_object({}) do |(k, v), result|
         
     | 
| 
      
 21 
     | 
    
         
            +
                        result[k] = v.slice(:data_type, :string_value, :binary_value)
         
     | 
| 
      
 22 
     | 
    
         
            +
                      end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
       17 
24 
     | 
    
         
             
                      {
         
     | 
| 
       18 
25 
     | 
    
         
             
                        id: message[:message_id],
         
     | 
| 
       19 
26 
     | 
    
         
             
                        message_body: message[:body],
         
     | 
| 
       20 
     | 
    
         
            -
                        message_attributes:  
     | 
| 
      
 27 
     | 
    
         
            +
                        message_attributes: message_attributes,
         
     | 
| 
       21 
28 
     | 
    
         
             
                        message_deduplication_id: attributes[:MessageDeduplicationId],
         
     | 
| 
       22 
29 
     | 
    
         
             
                        message_group_id: attributes[:MessageGroupId]
         
     | 
| 
       23 
30 
     | 
    
         
             
                      }
         
     | 
| 
         @@ -104,7 +111,7 @@ module Shoryuken 
     | 
|
| 
       104 
111 
     | 
    
         
             
                      attribute_size + body_size
         
     | 
| 
       105 
112 
     | 
    
         
             
                    end
         
     | 
| 
       106 
113 
     | 
    
         | 
| 
       107 
     | 
    
         
            -
                    def find_all(url, limit)
         
     | 
| 
      
 114 
     | 
    
         
            +
                    def find_all(url, limit, &block)
         
     | 
| 
       108 
115 
     | 
    
         
             
                      count = 0
         
     | 
| 
       109 
116 
     | 
    
         
             
                      batch_size = limit > 10 ? 10 : limit
         
     | 
| 
       110 
117 
     | 
    
         | 
| 
         @@ -119,7 +126,7 @@ module Shoryuken 
     | 
|
| 
       119 
126 
     | 
    
         
             
                          message_attribute_names: ['All']
         
     | 
| 
       120 
127 
     | 
    
         
             
                        ).messages || []
         
     | 
| 
       121 
128 
     | 
    
         | 
| 
       122 
     | 
    
         
            -
                        messages.each 
     | 
| 
      
 129 
     | 
    
         
            +
                        messages.each(&block)
         
     | 
| 
       123 
130 
     | 
    
         | 
| 
       124 
131 
     | 
    
         
             
                        count += messages.size
         
     | 
| 
       125 
132 
     | 
    
         | 
| 
         @@ -205,7 +212,8 @@ module Shoryuken 
     | 
|
| 
       205 
212 
     | 
    
         
             
                  end
         
     | 
| 
       206 
213 
     | 
    
         | 
| 
       207 
214 
     | 
    
         
             
                  desc 'requeue QUEUE-NAME PATH', 'Requeues messages from a dump file'
         
     | 
| 
       208 
     | 
    
         
            -
                  method_option :batch_size, aliases: '-n', type: :numeric, default: 10, 
     | 
| 
      
 215 
     | 
    
         
            +
                  method_option :batch_size, aliases: '-n', type: :numeric, default: 10,
         
     | 
| 
      
 216 
     | 
    
         
            +
                                             desc: 'maximum number of messages per batch to send'
         
     | 
| 
       209 
217 
     | 
    
         
             
                  def requeue(queue_name, path)
         
     | 
| 
       210 
218 
     | 
    
         
             
                    fail_task "Path #{path} not found" unless File.exist?(path)
         
     | 
| 
       211 
219 
     | 
    
         | 
    
        data/bin/shoryuken
    CHANGED
    
    | 
         @@ -26,7 +26,8 @@ module Shoryuken 
     | 
|
| 
       26 
26 
     | 
    
         
             
                  method_option :logfile,     aliases: '-L', type: :string,  desc: 'Path to logfile'
         
     | 
| 
       27 
27 
     | 
    
         
             
                  method_option :pidfile,     aliases: '-P', type: :string,  desc: 'Path to pidfile'
         
     | 
| 
       28 
28 
     | 
    
         
             
                  method_option :verbose,     aliases: '-v', type: :boolean, desc: 'Print more verbose output'
         
     | 
| 
       29 
     | 
    
         
            -
                  method_option :delay,       aliases: '-D', type: :numeric, 
     | 
| 
      
 29 
     | 
    
         
            +
                  method_option :delay,       aliases: '-D', type: :numeric,
         
     | 
| 
      
 30 
     | 
    
         
            +
                                              desc: 'Number of seconds to pause fetching from an empty queue'
         
     | 
| 
       30 
31 
     | 
    
         
             
                  def start
         
     | 
| 
       31 
32 
     | 
    
         
             
                    opts = options.to_h.symbolize_keys
         
     | 
| 
       32 
33 
     | 
    
         | 
    
        data/docker-compose.yml
    ADDED
    
    | 
         @@ -0,0 +1,22 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            services:
         
     | 
| 
      
 2 
     | 
    
         
            +
              localstack:
         
     | 
| 
      
 3 
     | 
    
         
            +
                image: localstack/localstack:latest
         
     | 
| 
      
 4 
     | 
    
         
            +
                container_name: localstack
         
     | 
| 
      
 5 
     | 
    
         
            +
                ports:
         
     | 
| 
      
 6 
     | 
    
         
            +
                  - "4566:4566"
         
     | 
| 
      
 7 
     | 
    
         
            +
                  - "4510-4559:4510-4559"
         
     | 
| 
      
 8 
     | 
    
         
            +
                environment:
         
     | 
| 
      
 9 
     | 
    
         
            +
                  - SERVICES=sqs
         
     | 
| 
      
 10 
     | 
    
         
            +
                  - DEBUG=${DEBUG:-0}
         
     | 
| 
      
 11 
     | 
    
         
            +
                  - DOCKER_HOST=unix:///var/run/docker.sock
         
     | 
| 
      
 12 
     | 
    
         
            +
                  - AWS_DEFAULT_REGION=us-east-1
         
     | 
| 
      
 13 
     | 
    
         
            +
                  - AWS_ACCESS_KEY_ID=test
         
     | 
| 
      
 14 
     | 
    
         
            +
                  - AWS_SECRET_ACCESS_KEY=test
         
     | 
| 
      
 15 
     | 
    
         
            +
                volumes:
         
     | 
| 
      
 16 
     | 
    
         
            +
                  - "${LOCALSTACK_VOLUME_DIR:-./.localstack}:/var/lib/localstack"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  - "/var/run/docker.sock:/var/run/docker.sock"
         
     | 
| 
      
 18 
     | 
    
         
            +
                healthcheck:
         
     | 
| 
      
 19 
     | 
    
         
            +
                  test: ["CMD", "curl", "-f", "http://localhost:4566/_localstack/health"]
         
     | 
| 
      
 20 
     | 
    
         
            +
                  interval: 5s
         
     | 
| 
      
 21 
     | 
    
         
            +
                  timeout: 10s
         
     | 
| 
      
 22 
     | 
    
         
            +
                  retries: 5
         
     | 
    
        data/gemfiles/rails_7_0.gemfile
    CHANGED
    
    | 
         @@ -1,22 +1,19 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # This file was generated by Appraisal
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            source  
     | 
| 
      
 3 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            group :test do
         
     | 
| 
       6 
     | 
    
         
            -
              gem  
     | 
| 
       7 
     | 
    
         
            -
              gem  
     | 
| 
       8 
     | 
    
         
            -
              gem  
     | 
| 
       9 
     | 
    
         
            -
              gem  
     | 
| 
       10 
     | 
    
         
            -
              gem  
     | 
| 
       11 
     | 
    
         
            -
              gem "multi_xml"
         
     | 
| 
       12 
     | 
    
         
            -
              gem "simplecov"
         
     | 
| 
      
 6 
     | 
    
         
            +
              gem 'activejob', '~> 7.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem 'httparty'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'multi_xml'
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem 'simplecov'
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem 'warning'
         
     | 
| 
       13 
11 
     | 
    
         
             
            end
         
     | 
| 
       14 
12 
     | 
    
         | 
| 
       15 
13 
     | 
    
         
             
            group :development do
         
     | 
| 
       16 
     | 
    
         
            -
              gem  
     | 
| 
       17 
     | 
    
         
            -
              gem  
     | 
| 
       18 
     | 
    
         
            -
              gem  
     | 
| 
       19 
     | 
    
         
            -
              gem "pry-byebug", ">= 3.10.1"
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'pry-byebug'
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem 'rubocop'
         
     | 
| 
       20 
17 
     | 
    
         
             
            end
         
     | 
| 
       21 
18 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
            gemspec path:  
     | 
| 
      
 19 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This file was generated by Appraisal
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 6 
     | 
    
         
            +
              gem 'activejob', '~> 7.1'
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem 'httparty'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'multi_xml'
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem 'simplecov'
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem 'warning'
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            group :development do
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'pry-byebug'
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem 'rubocop'
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This file was generated by Appraisal
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 6 
     | 
    
         
            +
              gem 'activejob', '~> 7.2'
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem 'httparty'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'multi_xml'
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem 'simplecov'
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem 'warning'
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            group :development do
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'pry-byebug'
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem 'rubocop'
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -0,0 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # This file was generated by Appraisal
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            source 'https://rubygems.org'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            group :test do
         
     | 
| 
      
 6 
     | 
    
         
            +
              gem 'activejob', '~> 8.0'
         
     | 
| 
      
 7 
     | 
    
         
            +
              gem 'httparty'
         
     | 
| 
      
 8 
     | 
    
         
            +
              gem 'multi_xml'
         
     | 
| 
      
 9 
     | 
    
         
            +
              gem 'simplecov'
         
     | 
| 
      
 10 
     | 
    
         
            +
              gem 'warning'
         
     | 
| 
      
 11 
     | 
    
         
            +
            end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            group :development do
         
     | 
| 
      
 14 
     | 
    
         
            +
              gem 'appraisal', git: 'https://github.com/thoughtbot/appraisal.git'
         
     | 
| 
      
 15 
     | 
    
         
            +
              gem 'pry-byebug'
         
     | 
| 
      
 16 
     | 
    
         
            +
              gem 'rubocop'
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            gemspec path: '../'
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Shoryuken
         
     | 
| 
       2 
4 
     | 
    
         
             
              class BodyParser
         
     | 
| 
       3 
5 
     | 
    
         
             
                class << self
         
     | 
| 
         @@ -16,7 +18,7 @@ module Shoryuken 
     | 
|
| 
       16 
18 
     | 
    
         
             
                        # JSON.parse
         
     | 
| 
       17 
19 
     | 
    
         
             
                        body_parser.parse(sqs_msg.body)
         
     | 
| 
       18 
20 
     | 
    
         
             
                      elsif body_parser.respond_to?(:load)
         
     | 
| 
       19 
     | 
    
         
            -
                        # see https://github.com/ 
     | 
| 
      
 21 
     | 
    
         
            +
                        # see https://github.com/ruby-shoryuken/shoryuken/pull/91
         
     | 
| 
       20 
22 
     | 
    
         
             
                        # JSON.load
         
     | 
| 
       21 
23 
     | 
    
         
             
                        body_parser.load(sqs_msg.body)
         
     | 
| 
       22 
24 
     | 
    
         
             
                      end
         
     | 
    
        data/lib/shoryuken/client.rb
    CHANGED
    
    
| 
         @@ -1,7 +1,9 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Shoryuken
         
     | 
| 
       2 
4 
     | 
    
         
             
              class DefaultWorkerRegistry < WorkerRegistry
         
     | 
| 
       3 
5 
     | 
    
         
             
                def initialize
         
     | 
| 
       4 
     | 
    
         
            -
                  @workers =  
     | 
| 
      
 6 
     | 
    
         
            +
                  @workers = Shoryuken::Helpers::AtomicHash.new
         
     | 
| 
       5 
7 
     | 
    
         
             
                end
         
     | 
| 
       6 
8 
     | 
    
         | 
| 
       7 
9 
     | 
    
         
             
                def batch_receive_messages?(queue)
         
     | 
| 
         @@ -19,10 +21,10 @@ module Shoryuken 
     | 
|
| 
       19 
21 
     | 
    
         
             
                                 message.message_attributes['shoryuken_class'][:string_value]
         
     | 
| 
       20 
22 
     | 
    
         | 
| 
       21 
23 
     | 
    
         
             
                  worker_class = begin
         
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
                    Shoryuken::Helpers::StringUtils.constantize(worker_class)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  rescue
         
     | 
| 
      
 26 
     | 
    
         
            +
                    @workers[queue]
         
     | 
| 
      
 27 
     | 
    
         
            +
                  end
         
     | 
| 
       26 
28 
     | 
    
         | 
| 
       27 
29 
     | 
    
         
             
                  worker_class.new if worker_class
         
     | 
| 
       28 
30 
     | 
    
         
             
                end
         
     | 
| 
         @@ -32,12 +34,10 @@ module Shoryuken 
     | 
|
| 
       32 
34 
     | 
    
         
             
                end
         
     | 
| 
       33 
35 
     | 
    
         | 
| 
       34 
36 
     | 
    
         
             
                def register_worker(queue, clazz)
         
     | 
| 
       35 
     | 
    
         
            -
                  if (worker_class = @workers[queue])
         
     | 
| 
       36 
     | 
    
         
            -
                     
     | 
| 
       37 
     | 
    
         
            -
                       
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                        "and Shoryuken doesn't support a batchable worker for a queue with multiple workers"
         
     | 
| 
       40 
     | 
    
         
            -
                    end
         
     | 
| 
      
 37 
     | 
    
         
            +
                  if (worker_class = @workers[queue]) && (worker_class.get_shoryuken_options['batch'] == true || clazz.get_shoryuken_options['batch'] == true)
         
     | 
| 
      
 38 
     | 
    
         
            +
                    fail ArgumentError, "Could not register #{clazz} for #{queue}, "\
         
     | 
| 
      
 39 
     | 
    
         
            +
                      "because #{worker_class} is already registered for this queue, "\
         
     | 
| 
      
 40 
     | 
    
         
            +
                      "and Shoryuken doesn't support a batchable worker for a queue with multiple workers"
         
     | 
| 
       41 
41 
     | 
    
         
             
                  end
         
     | 
| 
       42 
42 
     | 
    
         | 
| 
       43 
43 
     | 
    
         
             
                  @workers[queue] = clazz
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Shoryuken
         
     | 
| 
       2 
4 
     | 
    
         
             
              class EnvironmentLoader
         
     | 
| 
       3 
5 
     | 
    
         
             
                attr_reader :options
         
     | 
| 
         @@ -44,7 +46,7 @@ module Shoryuken 
     | 
|
| 
       44 
46 
     | 
    
         
             
                  fail ArgumentError, "The supplied config file #{path} does not exist" unless File.exist?(path)
         
     | 
| 
       45 
47 
     | 
    
         | 
| 
       46 
48 
     | 
    
         
             
                  if (result = YAML.load(ERB.new(IO.read(path)).result))
         
     | 
| 
       47 
     | 
    
         
            -
                     
     | 
| 
      
 49 
     | 
    
         
            +
                    Shoryuken::Helpers::HashUtils.deep_symbolize_keys(result)
         
     | 
| 
       48 
50 
     | 
    
         
             
                  else
         
     | 
| 
       49 
51 
     | 
    
         
             
                    {}
         
     | 
| 
       50 
52 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -161,11 +163,9 @@ module Shoryuken 
     | 
|
| 
       161 
163 
     | 
    
         
             
                  non_existent_queues = []
         
     | 
| 
       162 
164 
     | 
    
         | 
| 
       163 
165 
     | 
    
         
             
                  Shoryuken.ungrouped_queues.uniq.each do |queue|
         
     | 
| 
       164 
     | 
    
         
            -
                     
     | 
| 
       165 
     | 
    
         
            -
             
     | 
| 
       166 
     | 
    
         
            -
                     
     | 
| 
       167 
     | 
    
         
            -
                      non_existent_queues << queue
         
     | 
| 
       168 
     | 
    
         
            -
                    end
         
     | 
| 
      
 166 
     | 
    
         
            +
                    Shoryuken::Client.queues(queue)
         
     | 
| 
      
 167 
     | 
    
         
            +
                  rescue Aws::Errors::NoSuchEndpointError, Aws::SQS::Errors::NonExistentQueue
         
     | 
| 
      
 168 
     | 
    
         
            +
                    non_existent_queues << queue
         
     | 
| 
       169 
169 
     | 
    
         
             
                  end
         
     | 
| 
       170 
170 
     | 
    
         | 
| 
       171 
171 
     | 
    
         
             
                  return if non_existent_queues.none?
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # ActiveJob docs: http://edgeguides.rubyonrails.org/active_job_basics.html
         
     | 
| 
       2 
4 
     | 
    
         
             
            # Example adapters ref: https://github.com/rails/rails/tree/master/activejob/lib/active_job/queue_adapters
         
     | 
| 
       3 
5 
     | 
    
         | 
| 
         @@ -9,15 +11,15 @@ module ActiveJob 
     | 
|
| 
       9 
11 
     | 
    
         
             
                #
         
     | 
| 
       10 
12 
     | 
    
         
             
                # Shoryuken ("sho-ryu-ken") is a super-efficient AWS SQS thread based message processor.
         
     | 
| 
       11 
13 
     | 
    
         
             
                #
         
     | 
| 
       12 
     | 
    
         
            -
                # Read more about Shoryuken {here}[https://github.com/ 
     | 
| 
      
 14 
     | 
    
         
            +
                # Read more about Shoryuken {here}[https://github.com/ruby-shoryuken/shoryuken].
         
     | 
| 
       13 
15 
     | 
    
         
             
                #
         
     | 
| 
       14 
16 
     | 
    
         
             
                # To use Shoryuken set the queue_adapter config to +:shoryuken+.
         
     | 
| 
       15 
17 
     | 
    
         
             
                #
         
     | 
| 
       16 
18 
     | 
    
         
             
                #   Rails.application.config.active_job.queue_adapter = :shoryuken
         
     | 
| 
       17 
     | 
    
         
            -
                class ShoryukenAdapter
         
     | 
| 
      
 19 
     | 
    
         
            +
                class ShoryukenAdapter < ActiveJob::QueueAdapters::AbstractAdapter
         
     | 
| 
       18 
20 
     | 
    
         
             
                  class << self
         
     | 
| 
       19 
21 
     | 
    
         
             
                    def instance
         
     | 
| 
       20 
     | 
    
         
            -
                      # https://github.com/ 
     | 
| 
      
 22 
     | 
    
         
            +
                      # https://github.com/ruby-shoryuken/shoryuken/pull/174#issuecomment-174555657
         
     | 
| 
       21 
23 
     | 
    
         
             
                      @instance ||= new
         
     | 
| 
       22 
24 
     | 
    
         
             
                    end
         
     | 
| 
       23 
25 
     | 
    
         | 
| 
         @@ -30,7 +32,12 @@ module ActiveJob 
     | 
|
| 
       30 
32 
     | 
    
         
             
                    end
         
     | 
| 
       31 
33 
     | 
    
         
             
                  end
         
     | 
| 
       32 
34 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                   
     | 
| 
      
 35 
     | 
    
         
            +
                  # only required for Rails 7.2.x
         
     | 
| 
      
 36 
     | 
    
         
            +
                  def enqueue_after_transaction_commit?
         
     | 
| 
      
 37 
     | 
    
         
            +
                    true
         
     | 
| 
      
 38 
     | 
    
         
            +
                  end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  def enqueue(job, options = {}) # :nodoc:
         
     | 
| 
       34 
41 
     | 
    
         
             
                    register_worker!(job)
         
     | 
| 
       35 
42 
     | 
    
         | 
| 
       36 
43 
     | 
    
         
             
                    job.sqs_send_message_parameters.merge! options
         
     | 
| 
         @@ -41,7 +48,7 @@ module ActiveJob 
     | 
|
| 
       41 
48 
     | 
    
         
             
                    queue.send_message send_message_params
         
     | 
| 
       42 
49 
     | 
    
         
             
                  end
         
     | 
| 
       43 
50 
     | 
    
         | 
| 
       44 
     | 
    
         
            -
                  def enqueue_at(job, timestamp)  
     | 
| 
      
 51 
     | 
    
         
            +
                  def enqueue_at(job, timestamp) # :nodoc:
         
     | 
| 
       45 
52 
     | 
    
         
             
                    enqueue(job, delay_seconds: calculate_delay(timestamp))
         
     | 
| 
       46 
53 
     | 
    
         
             
                  end
         
     | 
| 
       47 
54 
     | 
    
         | 
| 
         @@ -80,7 +87,7 @@ module ActiveJob 
     | 
|
| 
       80 
87 
     | 
    
         
             
                    Shoryuken.register_worker(job.queue_name, JobWrapper)
         
     | 
| 
       81 
88 
     | 
    
         
             
                  end
         
     | 
| 
       82 
89 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
                  class JobWrapper  
     | 
| 
      
 90 
     | 
    
         
            +
                  class JobWrapper # :nodoc:
         
     | 
| 
       84 
91 
     | 
    
         
             
                    include Shoryuken::Worker
         
     | 
| 
       85 
92 
     | 
    
         | 
| 
       86 
93 
     | 
    
         
             
                    shoryuken_options body_parser: :json, auto_delete: true
         
     | 
| 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            # ActiveJob docs: http://edgeguides.rubyonrails.org/active_job_basics.html
         
     | 
| 
       2 
4 
     | 
    
         
             
            # Example adapters ref: https://github.com/rails/rails/tree/master/activejob/lib/active_job/queue_adapters
         
     | 
| 
       3 
5 
     | 
    
         
             
            module ActiveJob
         
     | 
| 
         @@ -30,11 +32,9 @@ module ActiveJob 
     | 
|
| 
       30 
32 
     | 
    
         
             
                  end
         
     | 
| 
       31 
33 
     | 
    
         | 
| 
       32 
34 
     | 
    
         
             
                  def error_handler
         
     | 
| 
       33 
     | 
    
         
            -
                    @error_handler ||=  
     | 
| 
       34 
     | 
    
         
            -
                       
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
                      }
         
     | 
| 
       37 
     | 
    
         
            -
                    end
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @error_handler ||= lambda { |error, job, _options|
         
     | 
| 
      
 36 
     | 
    
         
            +
                      Shoryuken.logger.warn("Failed to enqueue job: #{job.inspect} due to error: #{error}")
         
     | 
| 
      
 37 
     | 
    
         
            +
                    }
         
     | 
| 
       38 
38 
     | 
    
         
             
                  end
         
     | 
| 
       39 
39 
     | 
    
         | 
| 
       40 
40 
     | 
    
         
             
                  private
         
     | 
    
        data/lib/shoryuken/fetcher.rb
    CHANGED
    
    | 
         @@ -1,3 +1,5 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            module Shoryuken
         
     | 
| 
       2 
4 
     | 
    
         
             
              class Fetcher
         
     | 
| 
       3 
5 
     | 
    
         
             
                include Util
         
     | 
| 
         @@ -30,13 +32,13 @@ module Shoryuken 
     | 
|
| 
       30 
32 
     | 
    
         | 
| 
       31 
33 
     | 
    
         
             
                  begin
         
     | 
| 
       32 
34 
     | 
    
         
             
                    yield
         
     | 
| 
       33 
     | 
    
         
            -
                  rescue =>  
     | 
| 
      
 35 
     | 
    
         
            +
                  rescue => e
         
     | 
| 
       34 
36 
     | 
    
         
             
                    # Tries to auto retry connectivity errors
         
     | 
| 
       35 
37 
     | 
    
         
             
                    raise if attempts >= max_attempts
         
     | 
| 
       36 
38 
     | 
    
         | 
| 
       37 
39 
     | 
    
         
             
                    attempts += 1
         
     | 
| 
       38 
40 
     | 
    
         | 
| 
       39 
     | 
    
         
            -
                    logger.debug { "Retrying fetch attempt #{attempts} for #{ 
     | 
| 
      
 41 
     | 
    
         
            +
                    logger.debug { "Retrying fetch attempt #{attempts} for #{e.message}" }
         
     | 
| 
       40 
42 
     | 
    
         | 
| 
       41 
43 
     | 
    
         
             
                    sleep((1..5).to_a.sample)
         
     | 
| 
       42 
44 
     | 
    
         | 
| 
         @@ -0,0 +1,44 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module Shoryuken
         
     | 
| 
      
 4 
     | 
    
         
            +
              module Helpers
         
     | 
| 
      
 5 
     | 
    
         
            +
                # A thread-safe boolean implementation using AtomicCounter as base.
         
     | 
| 
      
 6 
     | 
    
         
            +
                # Drop-in replacement for Concurrent::AtomicBoolean without external dependencies.
         
     | 
| 
      
 7 
     | 
    
         
            +
                # Uses 1 for true and 0 for false internally.
         
     | 
| 
      
 8 
     | 
    
         
            +
                class AtomicBoolean < AtomicCounter
         
     | 
| 
      
 9 
     | 
    
         
            +
                  # Prevent misuse of counter operations on a boolean
         
     | 
| 
      
 10 
     | 
    
         
            +
                  undef_method :increment, :decrement
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def initialize(initial_value = false)
         
     | 
| 
      
 13 
     | 
    
         
            +
                    super(initial_value ? 1 : 0)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                  # Get the current value as boolean
         
     | 
| 
      
 17 
     | 
    
         
            +
                  def value
         
     | 
| 
      
 18 
     | 
    
         
            +
                    super != 0
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  # Set the value to true
         
     | 
| 
      
 22 
     | 
    
         
            +
                  def make_true
         
     | 
| 
      
 23 
     | 
    
         
            +
                    @mutex.synchronize { @value = 1 }
         
     | 
| 
      
 24 
     | 
    
         
            +
                    true
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  # Set the value to false
         
     | 
| 
      
 28 
     | 
    
         
            +
                  def make_false
         
     | 
| 
      
 29 
     | 
    
         
            +
                    @mutex.synchronize { @value = 0 }
         
     | 
| 
      
 30 
     | 
    
         
            +
                    false
         
     | 
| 
      
 31 
     | 
    
         
            +
                  end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                  # Check if the value is true
         
     | 
| 
      
 34 
     | 
    
         
            +
                  def true?
         
     | 
| 
      
 35 
     | 
    
         
            +
                    @mutex.synchronize { @value != 0 }
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  # Check if the value is false
         
     | 
| 
      
 39 
     | 
    
         
            +
                  def false?
         
     | 
| 
      
 40 
     | 
    
         
            +
                    @mutex.synchronize { @value == 0 }
         
     | 
| 
      
 41 
     | 
    
         
            +
                  end
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     |