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
 
| 
         @@ -0,0 +1,195 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            RSpec.describe Shoryuken::Polling::QueueConfiguration do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe '#initialize' do
         
     | 
| 
      
 5 
     | 
    
         
            +
                it 'creates configuration with name and options' do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  config = described_class.new('test_queue', { priority: :high })
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                  expect(config.name).to eq('test_queue')
         
     | 
| 
      
 9 
     | 
    
         
            +
                  expect(config.options).to eq({ priority: :high })
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                it 'creates configuration with empty options' do
         
     | 
| 
      
 13 
     | 
    
         
            +
                  config = described_class.new('simple_queue', {})
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                  expect(config.name).to eq('simple_queue')
         
     | 
| 
      
 16 
     | 
    
         
            +
                  expect(config.options).to eq({})
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                it 'accepts nil options' do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  config = described_class.new('queue', nil)
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
                  expect(config.name).to eq('queue')
         
     | 
| 
      
 23 
     | 
    
         
            +
                  expect(config.options).to be_nil
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
              end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              describe '#hash' do
         
     | 
| 
      
 28 
     | 
    
         
            +
                it 'returns hash based on queue name' do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  config1 = described_class.new('queue', {})
         
     | 
| 
      
 30 
     | 
    
         
            +
                  config2 = described_class.new('queue', { weight: 5 })
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
                  expect(config1.hash).to eq(config2.hash)
         
     | 
| 
      
 33 
     | 
    
         
            +
                  expect(config1.hash).to eq('queue'.hash)
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                it 'returns different hash for different queue names' do
         
     | 
| 
      
 37 
     | 
    
         
            +
                  config1 = described_class.new('queue1', {})
         
     | 
| 
      
 38 
     | 
    
         
            +
                  config2 = described_class.new('queue2', {})
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  expect(config1.hash).not_to eq(config2.hash)
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
              describe '#==' do
         
     | 
| 
      
 45 
     | 
    
         
            +
                context 'when comparing with another QueueConfiguration' do
         
     | 
| 
      
 46 
     | 
    
         
            +
                  it 'returns true for same name and options' do
         
     | 
| 
      
 47 
     | 
    
         
            +
                    config1 = described_class.new('queue', { weight: 5 })
         
     | 
| 
      
 48 
     | 
    
         
            +
                    config2 = described_class.new('queue', { weight: 5 })
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
                    expect(config1).to eq(config2)
         
     | 
| 
      
 51 
     | 
    
         
            +
                  end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
                  it 'returns false for same name but different options' do
         
     | 
| 
      
 54 
     | 
    
         
            +
                    config1 = described_class.new('queue', { weight: 5 })
         
     | 
| 
      
 55 
     | 
    
         
            +
                    config2 = described_class.new('queue', { weight: 10 })
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                    expect(config1).not_to eq(config2)
         
     | 
| 
      
 58 
     | 
    
         
            +
                  end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                  it 'returns false for different names' do
         
     | 
| 
      
 61 
     | 
    
         
            +
                    config1 = described_class.new('queue1', {})
         
     | 
| 
      
 62 
     | 
    
         
            +
                    config2 = described_class.new('queue2', {})
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
                    expect(config1).not_to eq(config2)
         
     | 
| 
      
 65 
     | 
    
         
            +
                  end
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                context 'when comparing with a string' do
         
     | 
| 
      
 69 
     | 
    
         
            +
                  it 'returns true when options are empty and names match' do
         
     | 
| 
      
 70 
     | 
    
         
            +
                    config = described_class.new('test_queue', {})
         
     | 
| 
      
 71 
     | 
    
         
            +
             
     | 
| 
      
 72 
     | 
    
         
            +
                    expect(config).to eq('test_queue')
         
     | 
| 
      
 73 
     | 
    
         
            +
                  end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
      
 75 
     | 
    
         
            +
                  it 'returns false when options are not empty' do
         
     | 
| 
      
 76 
     | 
    
         
            +
                    config = described_class.new('test_queue', { weight: 5 })
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                    expect(config).not_to eq('test_queue')
         
     | 
| 
      
 79 
     | 
    
         
            +
                  end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  it 'returns false when names do not match' do
         
     | 
| 
      
 82 
     | 
    
         
            +
                    config = described_class.new('queue1', {})
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                    expect(config).not_to eq('queue2')
         
     | 
| 
      
 85 
     | 
    
         
            +
                  end
         
     | 
| 
      
 86 
     | 
    
         
            +
                end
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                context 'when comparing with other objects' do
         
     | 
| 
      
 89 
     | 
    
         
            +
                  it 'returns false for non-string, non-QueueConfiguration objects' do
         
     | 
| 
      
 90 
     | 
    
         
            +
                    config = described_class.new('queue', {})
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
                    expect(config).not_to eq(123)
         
     | 
| 
      
 93 
     | 
    
         
            +
                    expect(config).not_to eq([])
         
     | 
| 
      
 94 
     | 
    
         
            +
                    expect(config).not_to eq({ name: 'queue' })
         
     | 
| 
      
 95 
     | 
    
         
            +
                  end
         
     | 
| 
      
 96 
     | 
    
         
            +
                end
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              describe '#eql?' do
         
     | 
| 
      
 100 
     | 
    
         
            +
                it 'behaves the same as ==' do
         
     | 
| 
      
 101 
     | 
    
         
            +
                  config1 = described_class.new('queue', {})
         
     | 
| 
      
 102 
     | 
    
         
            +
                  config2 = described_class.new('queue', {})
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                  expect(config1.eql?(config2)).to eq(config1 == config2)
         
     | 
| 
      
 105 
     | 
    
         
            +
                  expect(config1.eql?('queue')).to eq(config1 == 'queue')
         
     | 
| 
      
 106 
     | 
    
         
            +
                end
         
     | 
| 
      
 107 
     | 
    
         
            +
              end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
              describe '#to_s' do
         
     | 
| 
      
 110 
     | 
    
         
            +
                context 'when options are empty' do
         
     | 
| 
      
 111 
     | 
    
         
            +
                  it 'returns just the queue name' do
         
     | 
| 
      
 112 
     | 
    
         
            +
                    config = described_class.new('simple_queue', {})
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                    expect(config.to_s).to eq('simple_queue')
         
     | 
| 
      
 115 
     | 
    
         
            +
                  end
         
     | 
| 
      
 116 
     | 
    
         
            +
                end
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                context 'when options are present' do
         
     | 
| 
      
 119 
     | 
    
         
            +
                  it 'returns detailed representation with options' do
         
     | 
| 
      
 120 
     | 
    
         
            +
                    config = described_class.new('complex_queue', { priority: :high, weight: 5 })
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                    expect(config.to_s).to include('#<QueueConfiguration complex_queue options={')
         
     | 
| 
      
 123 
     | 
    
         
            +
                  end
         
     | 
| 
      
 124 
     | 
    
         
            +
             
     | 
| 
      
 125 
     | 
    
         
            +
                  it 'handles single option' do
         
     | 
| 
      
 126 
     | 
    
         
            +
                    config = described_class.new('weighted_queue', { weight: 10 })
         
     | 
| 
      
 127 
     | 
    
         
            +
             
     | 
| 
      
 128 
     | 
    
         
            +
                    expect(config.to_s).to include('#<QueueConfiguration weighted_queue options={')
         
     | 
| 
      
 129 
     | 
    
         
            +
                  end
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
             
     | 
| 
      
 132 
     | 
    
         
            +
                context 'when options are nil' do
         
     | 
| 
      
 133 
     | 
    
         
            +
                  it 'returns detailed representation' do
         
     | 
| 
      
 134 
     | 
    
         
            +
                    config = described_class.new('nil_options_queue', nil)
         
     | 
| 
      
 135 
     | 
    
         
            +
             
     | 
| 
      
 136 
     | 
    
         
            +
                    expect(config.to_s).to eq('#<QueueConfiguration nil_options_queue options=nil>')
         
     | 
| 
      
 137 
     | 
    
         
            +
                  end
         
     | 
| 
      
 138 
     | 
    
         
            +
                end
         
     | 
| 
      
 139 
     | 
    
         
            +
              end
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
              describe 'struct behavior' do
         
     | 
| 
      
 142 
     | 
    
         
            +
                it 'provides attribute accessors' do
         
     | 
| 
      
 143 
     | 
    
         
            +
                  config = described_class.new('queue', { weight: 5 })
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
                  expect(config.name).to eq('queue')
         
     | 
| 
      
 146 
     | 
    
         
            +
                  expect(config.options).to eq({ weight: 5 })
         
     | 
| 
      
 147 
     | 
    
         
            +
                end
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
      
 149 
     | 
    
         
            +
                it 'allows attribute modification' do
         
     | 
| 
      
 150 
     | 
    
         
            +
                  config = described_class.new('queue', {})
         
     | 
| 
      
 151 
     | 
    
         
            +
             
     | 
| 
      
 152 
     | 
    
         
            +
                  config.name = 'new_queue'
         
     | 
| 
      
 153 
     | 
    
         
            +
                  config.options = { priority: :low }
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                  expect(config.name).to eq('new_queue')
         
     | 
| 
      
 156 
     | 
    
         
            +
                  expect(config.options).to eq({ priority: :low })
         
     | 
| 
      
 157 
     | 
    
         
            +
                end
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
                it 'supports array-like access' do
         
     | 
| 
      
 160 
     | 
    
         
            +
                  config = described_class.new('queue', { weight: 5 })
         
     | 
| 
      
 161 
     | 
    
         
            +
             
     | 
| 
      
 162 
     | 
    
         
            +
                  expect(config[0]).to eq('queue')
         
     | 
| 
      
 163 
     | 
    
         
            +
                  expect(config[1]).to eq({ weight: 5 })
         
     | 
| 
      
 164 
     | 
    
         
            +
                end
         
     | 
| 
      
 165 
     | 
    
         
            +
              end
         
     | 
| 
      
 166 
     | 
    
         
            +
             
     | 
| 
      
 167 
     | 
    
         
            +
              describe 'usage as hash key' do
         
     | 
| 
      
 168 
     | 
    
         
            +
                it 'can be used as hash keys' do
         
     | 
| 
      
 169 
     | 
    
         
            +
                  config1 = described_class.new('queue', {})
         
     | 
| 
      
 170 
     | 
    
         
            +
                  config2 = described_class.new('queue', {})  # Same config
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                  hash = {}
         
     | 
| 
      
 173 
     | 
    
         
            +
                  hash[config1] = 'value1'
         
     | 
| 
      
 174 
     | 
    
         
            +
                  hash[config2] = 'value2'
         
     | 
| 
      
 175 
     | 
    
         
            +
             
     | 
| 
      
 176 
     | 
    
         
            +
                  # Same queue name and options should use same hash key
         
     | 
| 
      
 177 
     | 
    
         
            +
                  expect(hash[config1]).to eq('value2')
         
     | 
| 
      
 178 
     | 
    
         
            +
                  expect(hash[config2]).to eq('value2')
         
     | 
| 
      
 179 
     | 
    
         
            +
                  expect(hash.size).to eq(1)
         
     | 
| 
      
 180 
     | 
    
         
            +
                end
         
     | 
| 
      
 181 
     | 
    
         
            +
             
     | 
| 
      
 182 
     | 
    
         
            +
                it 'different queue names create different keys' do
         
     | 
| 
      
 183 
     | 
    
         
            +
                  config1 = described_class.new('queue1', {})
         
     | 
| 
      
 184 
     | 
    
         
            +
                  config2 = described_class.new('queue2', {})
         
     | 
| 
      
 185 
     | 
    
         
            +
             
     | 
| 
      
 186 
     | 
    
         
            +
                  hash = {}
         
     | 
| 
      
 187 
     | 
    
         
            +
                  hash[config1] = 'value1'
         
     | 
| 
      
 188 
     | 
    
         
            +
                  hash[config2] = 'value2'
         
     | 
| 
      
 189 
     | 
    
         
            +
             
     | 
| 
      
 190 
     | 
    
         
            +
                  expect(hash[config1]).to eq('value1')
         
     | 
| 
      
 191 
     | 
    
         
            +
                  expect(hash[config2]).to eq('value2')
         
     | 
| 
      
 192 
     | 
    
         
            +
                  expect(hash.size).to eq(2)
         
     | 
| 
      
 193 
     | 
    
         
            +
                end
         
     | 
| 
      
 194 
     | 
    
         
            +
              end
         
     | 
| 
      
 195 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,6 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            # rubocop:disable Metrics/BlockLength
         
     | 
| 
       4 
3 
     | 
    
         
             
            RSpec.describe Shoryuken::Queue do
         
     | 
| 
       5 
4 
     | 
    
         
             
              let(:credentials) { Aws::Credentials.new('access_key_id', 'secret_access_key') }
         
     | 
| 
       6 
5 
     | 
    
         
             
              let(:sqs) { Aws::SQS::Client.new(stub_responses: true, credentials: credentials) }
         
     | 
| 
         @@ -30,7 +29,7 @@ RSpec.describe Shoryuken::Queue do 
     | 
|
| 
       30 
29 
     | 
    
         
             
                  let(:queue_url) { "http://localhost:4576/queue/#{queue_name}" }
         
     | 
| 
       31 
30 
     | 
    
         | 
| 
       32 
31 
     | 
    
         
             
                  it 'instantiates by URL and validate the URL' do
         
     | 
| 
       33 
     | 
    
         
            -
                    # See https://github.com/ 
     | 
| 
      
 32 
     | 
    
         
            +
                    # See https://github.com/ruby-shoryuken/shoryuken/pull/551
         
     | 
| 
       34 
33 
     | 
    
         
             
                    expect_any_instance_of(described_class).to receive(:fifo?).and_return(false)
         
     | 
| 
       35 
34 
     | 
    
         | 
| 
       36 
35 
     | 
    
         
             
                    subject = described_class.new(sqs, queue_url)
         
     | 
    
        data/spec/shoryuken/util_spec.rb
    CHANGED
    
    
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            RSpec.describe Shoryuken::Worker::InlineExecutor do
         
     | 
| 
       4 
4 
     | 
    
         
             
              before do
         
     | 
| 
         @@ -11,6 +11,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do 
     | 
|
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
                  TestWorker.perform_async('test')
         
     | 
| 
       13 
13 
     | 
    
         
             
                end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                it 'properly sets message_attributes' do
         
     | 
| 
      
 16 
     | 
    
         
            +
                  custom_attributes = {
         
     | 
| 
      
 17 
     | 
    
         
            +
                    'custom_key' => { string_value: 'custom_value', data_type: 'String' }
         
     | 
| 
      
 18 
     | 
    
         
            +
                  }
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                  expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msg, _|
         
     | 
| 
      
 21 
     | 
    
         
            +
                    expect(sqs_msg.message_attributes).to include('shoryuken_class')
         
     | 
| 
      
 22 
     | 
    
         
            +
                    expect(sqs_msg.message_attributes).to include('custom_key')
         
     | 
| 
      
 23 
     | 
    
         
            +
                    expect(sqs_msg.message_attributes['custom_key'][:string_value]).to eq('custom_value')
         
     | 
| 
      
 24 
     | 
    
         
            +
                  end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                  TestWorker.perform_async('test', message_attributes: custom_attributes)
         
     | 
| 
      
 27 
     | 
    
         
            +
                end
         
     | 
| 
       14 
28 
     | 
    
         
             
              end
         
     | 
| 
       15 
29 
     | 
    
         | 
| 
       16 
30 
     | 
    
         
             
              describe '.perform_in' do
         
     | 
| 
         @@ -19,6 +33,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do 
     | 
|
| 
       19 
33 
     | 
    
         | 
| 
       20 
34 
     | 
    
         
             
                  TestWorker.perform_in(60, 'test')
         
     | 
| 
       21 
35 
     | 
    
         
             
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                it 'properly passes message_attributes to perform_async' do
         
     | 
| 
      
 38 
     | 
    
         
            +
                  custom_attributes = {
         
     | 
| 
      
 39 
     | 
    
         
            +
                    'custom_key' => { string_value: 'custom_value', data_type: 'String' }
         
     | 
| 
      
 40 
     | 
    
         
            +
                  }
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msg, _|
         
     | 
| 
      
 43 
     | 
    
         
            +
                    expect(sqs_msg.message_attributes).to include('shoryuken_class')
         
     | 
| 
      
 44 
     | 
    
         
            +
                    expect(sqs_msg.message_attributes).to include('custom_key')
         
     | 
| 
      
 45 
     | 
    
         
            +
                    expect(sqs_msg.message_attributes['custom_key'][:string_value]).to eq('custom_value')
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                  TestWorker.perform_in(60, 'test', message_attributes: custom_attributes)
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
       22 
50 
     | 
    
         
             
              end
         
     | 
| 
       23 
51 
     | 
    
         | 
| 
       24 
52 
     | 
    
         
             
              context 'batch' do
         
     | 
| 
         @@ -36,6 +64,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do 
     | 
|
| 
       36 
64 
     | 
    
         | 
| 
       37 
65 
     | 
    
         
             
                    TestWorker.perform_async('test')
         
     | 
| 
       38 
66 
     | 
    
         
             
                  end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  it 'properly passes message_attributes with batch' do
         
     | 
| 
      
 69 
     | 
    
         
            +
                    custom_attributes = {
         
     | 
| 
      
 70 
     | 
    
         
            +
                      'custom_key' => { string_value: 'custom_value', data_type: 'String' }
         
     | 
| 
      
 71 
     | 
    
         
            +
                    }
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                    expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msgs, _|
         
     | 
| 
      
 74 
     | 
    
         
            +
                      expect(sqs_msgs.first.message_attributes).to include('shoryuken_class')
         
     | 
| 
      
 75 
     | 
    
         
            +
                      expect(sqs_msgs.first.message_attributes).to include('custom_key')
         
     | 
| 
      
 76 
     | 
    
         
            +
                      expect(sqs_msgs.first.message_attributes['custom_key'][:string_value]).to eq('custom_value')
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                    TestWorker.perform_async('test', message_attributes: custom_attributes)
         
     | 
| 
      
 80 
     | 
    
         
            +
                  end
         
     | 
| 
       39 
81 
     | 
    
         
             
                end
         
     | 
| 
       40 
82 
     | 
    
         | 
| 
       41 
83 
     | 
    
         
             
                describe '.perform_in' do
         
     | 
| 
         @@ -44,6 +86,20 @@ RSpec.describe Shoryuken::Worker::InlineExecutor do 
     | 
|
| 
       44 
86 
     | 
    
         | 
| 
       45 
87 
     | 
    
         
             
                    TestWorker.perform_in(60, 'test')
         
     | 
| 
       46 
88 
     | 
    
         
             
                  end
         
     | 
| 
      
 89 
     | 
    
         
            +
             
     | 
| 
      
 90 
     | 
    
         
            +
                  it 'properly passes message_attributes with batch' do
         
     | 
| 
      
 91 
     | 
    
         
            +
                    custom_attributes = {
         
     | 
| 
      
 92 
     | 
    
         
            +
                      'custom_key' => { string_value: 'custom_value', data_type: 'String' }
         
     | 
| 
      
 93 
     | 
    
         
            +
                    }
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                    expect_any_instance_of(TestWorker).to receive(:perform) do |_, sqs_msgs, _|
         
     | 
| 
      
 96 
     | 
    
         
            +
                      expect(sqs_msgs.first.message_attributes).to include('shoryuken_class')
         
     | 
| 
      
 97 
     | 
    
         
            +
                      expect(sqs_msgs.first.message_attributes).to include('custom_key')
         
     | 
| 
      
 98 
     | 
    
         
            +
                      expect(sqs_msgs.first.message_attributes['custom_key'][:string_value]).to eq('custom_value')
         
     | 
| 
      
 99 
     | 
    
         
            +
                    end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                    TestWorker.perform_in(60, 'test', message_attributes: custom_attributes)
         
     | 
| 
      
 102 
     | 
    
         
            +
                  end
         
     | 
| 
       47 
103 
     | 
    
         
             
                end
         
     | 
| 
       48 
104 
     | 
    
         
             
              end
         
     | 
| 
       49 
105 
     | 
    
         
             
            end
         
     | 
| 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            RSpec.describe Shoryuken::Worker do
         
     | 
| 
       4 
4 
     | 
    
         
             
              let(:sqs_queue) { double 'SQS Queue' }
         
     | 
| 
         @@ -108,14 +108,16 @@ RSpec.describe Shoryuken::Worker do 
     | 
|
| 
       108 
108 
     | 
    
         
             
              end
         
     | 
| 
       109 
109 
     | 
    
         | 
| 
       110 
110 
     | 
    
         
             
              describe '.server_middleware' do
         
     | 
| 
       111 
     | 
    
         
            -
                 
     | 
| 
       112 
     | 
    
         
            -
                   
     | 
| 
      
 111 
     | 
    
         
            +
                let(:fake_middleware_class) do
         
     | 
| 
      
 112 
     | 
    
         
            +
                  Class.new do
         
     | 
| 
       113 
113 
     | 
    
         
             
                    def call(*_args)
         
     | 
| 
       114 
114 
     | 
    
         
             
                      yield
         
     | 
| 
       115 
115 
     | 
    
         
             
                    end
         
     | 
| 
       116 
116 
     | 
    
         
             
                  end
         
     | 
| 
       117 
117 
     | 
    
         
             
                end
         
     | 
| 
       118 
118 
     | 
    
         | 
| 
      
 119 
     | 
    
         
            +
                before { fake_middleware_class }
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
       119 
121 
     | 
    
         
             
                context 'no middleware is defined in the worker' do
         
     | 
| 
       120 
122 
     | 
    
         
             
                  it 'returns the list of global middlewares' do
         
     | 
| 
       121 
123 
     | 
    
         
             
                    expect(TestWorker.server_middleware).to satisfy do |chain|
         
     | 
| 
         @@ -147,27 +149,29 @@ RSpec.describe Shoryuken::Worker do 
     | 
|
| 
       147 
149 
     | 
    
         
             
                end
         
     | 
| 
       148 
150 
     | 
    
         | 
| 
       149 
151 
     | 
    
         
             
                context 'the worker modifies the chain' do
         
     | 
| 
       150 
     | 
    
         
            -
                   
     | 
| 
       151 
     | 
    
         
            -
                     
     | 
| 
      
 152 
     | 
    
         
            +
                  let(:new_test_worker3_class) do
         
     | 
| 
      
 153 
     | 
    
         
            +
                    ref = fake_middleware_class
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
      
 155 
     | 
    
         
            +
                    Class.new do
         
     | 
| 
       152 
156 
     | 
    
         
             
                      include Shoryuken::Worker
         
     | 
| 
       153 
157 
     | 
    
         | 
| 
       154 
158 
     | 
    
         
             
                      server_middleware do |chain|
         
     | 
| 
       155 
159 
     | 
    
         
             
                        chain.remove Shoryuken::Middleware::Server::Timing
         
     | 
| 
       156 
     | 
    
         
            -
                        chain.insert_before Shoryuken::Middleware::Server::AutoDelete,  
     | 
| 
      
 160 
     | 
    
         
            +
                        chain.insert_before Shoryuken::Middleware::Server::AutoDelete, ref
         
     | 
| 
       157 
161 
     | 
    
         
             
                      end
         
     | 
| 
       158 
162 
     | 
    
         
             
                    end
         
     | 
| 
       159 
163 
     | 
    
         
             
                  end
         
     | 
| 
       160 
164 
     | 
    
         | 
| 
       161 
165 
     | 
    
         
             
                  it 'returns the combined global and worker middlewares' do
         
     | 
| 
       162 
     | 
    
         
            -
                    expect( 
     | 
| 
      
 166 
     | 
    
         
            +
                    expect(new_test_worker3_class.server_middleware).not_to satisfy do |chain|
         
     | 
| 
       163 
167 
     | 
    
         
             
                      chain.exists?(Shoryuken::Middleware::Server::Timing)
         
     | 
| 
       164 
168 
     | 
    
         
             
                    end
         
     | 
| 
       165 
169 
     | 
    
         | 
| 
       166 
     | 
    
         
            -
                    expect( 
     | 
| 
       167 
     | 
    
         
            -
                      chain.exists?( 
     | 
| 
      
 170 
     | 
    
         
            +
                    expect(new_test_worker3_class.server_middleware).to satisfy do |chain|
         
     | 
| 
      
 171 
     | 
    
         
            +
                      chain.exists?(fake_middleware_class)
         
     | 
| 
       168 
172 
     | 
    
         
             
                    end
         
     | 
| 
       169 
173 
     | 
    
         | 
| 
       170 
     | 
    
         
            -
                    expect( 
     | 
| 
      
 174 
     | 
    
         
            +
                    expect(new_test_worker3_class.server_middleware).to satisfy do |chain|
         
     | 
| 
       171 
175 
     | 
    
         
             
                      chain.exists?(Shoryuken::Middleware::Server::AutoDelete)
         
     | 
| 
       172 
176 
     | 
    
         
             
                    end
         
     | 
| 
       173 
177 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -182,7 +186,7 @@ RSpec.describe Shoryuken::Worker do 
     | 
|
| 
       182 
186 
     | 
    
         
             
                    end
         
     | 
| 
       183 
187 
     | 
    
         | 
| 
       184 
188 
     | 
    
         
             
                    expect(Shoryuken.server_middleware).not_to satisfy do |chain|
         
     | 
| 
       185 
     | 
    
         
            -
                      chain.exists?( 
     | 
| 
      
 189 
     | 
    
         
            +
                      chain.exists?(fake_middleware_class)
         
     | 
| 
       186 
190 
     | 
    
         
             
                    end
         
     | 
| 
       187 
191 
     | 
    
         
             
                  end
         
     | 
| 
       188 
192 
     | 
    
         
             
                end
         
     | 
    
        data/spec/shoryuken_spec.rb
    CHANGED
    
    
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,3 +1,19 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            Warning[:performance] = true if RUBY_VERSION >= '3.3'
         
     | 
| 
      
 4 
     | 
    
         
            +
            Warning[:deprecated] = true
         
     | 
| 
      
 5 
     | 
    
         
            +
            $VERBOSE = true
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require 'warning'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            Warning.process do |warning|
         
     | 
| 
      
 10 
     | 
    
         
            +
              next unless warning.include?(Dir.pwd)
         
     | 
| 
      
 11 
     | 
    
         
            +
              next if warning.include?('useless use of a variable in void context') && warning.include?('core_ext')
         
     | 
| 
      
 12 
     | 
    
         
            +
              next if warning.include?('vendor/')
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
              raise "Warning in your code: #{warning}"
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
       1 
17 
     | 
    
         
             
            require 'bundler/setup'
         
     | 
| 
       2 
18 
     | 
    
         
             
            Bundler.setup
         
     | 
| 
       3 
19 
     | 
    
         | 
| 
         @@ -10,12 +26,11 @@ require 'shoryuken' 
     | 
|
| 
       10 
26 
     | 
    
         
             
            require 'json'
         
     | 
| 
       11 
27 
     | 
    
         
             
            require 'dotenv'
         
     | 
| 
       12 
28 
     | 
    
         
             
            require 'securerandom'
         
     | 
| 
      
 29 
     | 
    
         
            +
            require 'ostruct'
         
     | 
| 
       13 
30 
     | 
    
         
             
            Dotenv.load
         
     | 
| 
       14 
31 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
              SimpleCov.start
         
     | 
| 
       18 
     | 
    
         
            -
            end
         
     | 
| 
      
 32 
     | 
    
         
            +
            require 'simplecov'
         
     | 
| 
      
 33 
     | 
    
         
            +
            SimpleCov.start
         
     | 
| 
       19 
34 
     | 
    
         | 
| 
       20 
35 
     | 
    
         
             
            config_file = File.join(File.expand_path('..', __dir__), 'spec', 'shoryuken.yml')
         
     | 
| 
       21 
36 
     | 
    
         |