sidekiq 3.3.2 → 3.3.3
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.
Potentially problematic release.
This version of sidekiq might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/COMM-LICENSE +2 -0
- data/Changes.md +7 -0
- data/Pro-2.0-Upgrade.md +27 -6
- data/Pro-Changes.md +9 -1
- data/README.md +6 -6
- data/lib/sidekiq/api.rb +8 -8
- data/lib/sidekiq/cli.rb +5 -0
- data/lib/sidekiq/extensions/action_mailer.rb +0 -1
- data/lib/sidekiq/launcher.rb +2 -0
- data/lib/sidekiq/middleware/chain.rb +2 -2
- data/lib/sidekiq/middleware/server/retry_jobs.rb +1 -1
- data/lib/sidekiq/version.rb +1 -1
- data/lib/sidekiq/worker.rb +3 -3
- data/test/test_api.rb +1 -3
- data/test/test_scheduling.rb +9 -0
- data/web/assets/stylesheets/application.css +12 -0
- data/web/views/_footer.erb +2 -2
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4895c316f5c9f592745594ac4984e150fbf5ea62
         | 
| 4 | 
            +
              data.tar.gz: b78f6b9242d8a981a60d3fbe28a08c3c16b839af
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 9134b87eee18dc46b1e95d9190ee3a3f0d5b9426f5b6953d9b55aee39d9fd6e2441b9133fa797e137d8cfdc50c6e99fbff1c74195fe065ff3d84b4e8869333fe
         | 
| 7 | 
            +
              data.tar.gz: 23767242d2d5911526cae5b5061d050a363947cc9f21f7dbc336eb6d5605ab470a0733b2ab6979e33b3dd81969bdd282958ce69f8a6a3a4683fdceb71dfcc4a1
         | 
    
        data/.travis.yml
    CHANGED
    
    
    
        data/COMM-LICENSE
    CHANGED
    
    | @@ -24,6 +24,8 @@ You may not, without Our prior written consent, redistribute the Software or Mod | |
| 24 24 |  | 
| 25 25 | 
             
            You may not redistribute the Software as part of a product, "appliance" or "virtual server".  You may not redistribute the Software on any server which is not directly under Your control.
         | 
| 26 26 |  | 
| 27 | 
            +
            You may not publicize your unique "Source URL" for Sidekiq Pro.  If your unique Source URL is ever publicized, We reserve the right to terminate your access without notice.
         | 
| 28 | 
            +
             | 
| 27 29 | 
             
            UNDER NO CIRCUMSTANCES MAY YOU USE THE SOFTWARE FOR A PRODUCT THAT IS INTENDED FOR SOFTWARE OR APPLICATION DEVELOPMENT PURPOSES.
         | 
| 28 30 |  | 
| 29 31 | 
             
            The Open Source version of the Software (“LGPL Version”) is licensed
         | 
    
        data/Changes.md
    CHANGED
    
    
    
        data/Pro-2.0-Upgrade.md
    CHANGED
    
    | @@ -15,6 +15,9 @@ available. | |
| 15 15 | 
             
            **Note that you CANNOT go back to Pro 1.x once you've created batches
         | 
| 16 16 | 
             
            with 2.x.  The new batches will not process correctly with 1.x.**
         | 
| 17 17 |  | 
| 18 | 
            +
            **If you are on a version of Sidekiq Pro <1.5, you should upgrade to the
         | 
| 19 | 
            +
            latest 1.x version and run it for a week before upgrading to 2.0.**
         | 
| 20 | 
            +
             | 
| 18 21 | 
             
            ## Nested Batches
         | 
| 19 22 |  | 
| 20 23 | 
             
            Batches can now be nested within the `jobs` method.
         | 
| @@ -35,7 +38,7 @@ a.jobs do | |
| 35 38 | 
             
            end
         | 
| 36 39 | 
             
            ```
         | 
| 37 40 |  | 
| 38 | 
            -
            Parent batch callbacks are not processed until  | 
| 41 | 
            +
            Parent batch callbacks are not processed until all child batch callbacks have
         | 
| 39 42 | 
             
            run successfully.  In the example above, `MyCallback` will always fire
         | 
| 40 43 | 
             
            before `SomeCallback` because `b` is considered a child of `a`.
         | 
| 41 44 |  | 
| @@ -58,6 +61,8 @@ def perform(*args) | |
| 58 61 | 
             
            end
         | 
| 59 62 | 
             
            ```
         | 
| 60 63 |  | 
| 64 | 
            +
            More context: [#1485]
         | 
| 65 | 
            +
             | 
| 61 66 | 
             
            ## Batch Data
         | 
| 62 67 |  | 
| 63 68 | 
             
            The batch data model was overhauled.  Batch data should take
         | 
| @@ -78,14 +83,22 @@ savings but real world savings should be even greater. | |
| 78 83 | 
             
            **There's no data migration required.  Sidekiq Pro 2.0 transparently handles
         | 
| 79 84 | 
             
            both old and new format.**
         | 
| 80 85 |  | 
| 86 | 
            +
            More context: [#2130]
         | 
| 87 | 
            +
             | 
| 81 88 | 
             
            ## Reliability
         | 
| 82 89 |  | 
| 83 90 | 
             
            2.0 brings a new reliable scheduler which uses Lua inside Redis so enqueuing
         | 
| 84 91 | 
             
            scheduled jobs is atomic.  Benchmarks show it 50x faster when enqueuing
         | 
| 85 | 
            -
            lots of jobs. | 
| 86 | 
            -
             | 
| 87 | 
            -
             | 
| 88 | 
            -
             | 
| 92 | 
            +
            lots of jobs.
         | 
| 93 | 
            +
             | 
| 94 | 
            +
            **Two caveats**:
         | 
| 95 | 
            +
            - Client-side middleware is not executed
         | 
| 96 | 
            +
              for each job when enqueued with the reliable scheduler.  No Sidekiq or
         | 
| 97 | 
            +
              Sidekiq Pro functionality is affected by this change but some 3rd party
         | 
| 98 | 
            +
              plugins might be.
         | 
| 99 | 
            +
            - The Lua script used inside the reliable scheduler is not safe for use
         | 
| 100 | 
            +
              with Redis Cluster, Redis Sentinel or other distributed Redis solutions.
         | 
| 101 | 
            +
              It is safe to use with a typical master/slave replication setup.
         | 
| 89 102 |  | 
| 90 103 | 
             
            **You no longer require anything to use the Reliability features.**
         | 
| 91 104 |  | 
| @@ -101,6 +114,8 @@ end | |
| 101 114 | 
             
            Sidekiq::Client.reliable_push!
         | 
| 102 115 | 
             
            ```
         | 
| 103 116 |  | 
| 117 | 
            +
            More context: [#2130]
         | 
| 118 | 
            +
             | 
| 104 119 | 
             
            ## Other Changes
         | 
| 105 120 |  | 
| 106 121 | 
             
            * You must require `sidekiq/pro/notifications` if you want to use the
         | 
| @@ -109,7 +124,13 @@ Sidekiq::Client.reliable_push! | |
| 109 124 | 
             
            * Several classes have been renamed.  Generally these classes are ones
         | 
| 110 125 | 
             
              you should not need to require/use in your own code, e.g. the Batch
         | 
| 111 126 | 
             
              middleware.
         | 
| 112 | 
            -
            *  | 
| 127 | 
            +
            * You can add `attr_accessor :jid` to a Batch callback class and Sidekiq
         | 
| 128 | 
            +
              Pro will set it to the jid of the callback job. [#2178]
         | 
| 129 | 
            +
            * There's now an official API to iterate all known Batches [#2191]
         | 
| 130 | 
            +
            ```ruby
         | 
| 131 | 
            +
            Sidekiq::BatchSet.new.each {|status| p status.bid }
         | 
| 132 | 
            +
            ```
         | 
| 133 | 
            +
            * The Web UI now shows the Sidekiq Pro version in the footer. [#1991]
         | 
| 113 134 |  | 
| 114 135 | 
             
            ## Thanks
         | 
| 115 136 |  | 
    
        data/Pro-Changes.md
    CHANGED
    
    | @@ -4,7 +4,15 @@ Sidekiq Pro Changelog | |
| 4 4 | 
             
            Please see [http://sidekiq.org/pro](http://sidekiq.org/pro) for more details and how to buy.
         | 
| 5 5 |  | 
| 6 6 |  | 
| 7 | 
            -
            2.0. | 
| 7 | 
            +
            2.0.1
         | 
| 8 | 
            +
            -----------
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            - Add `batch.callback_queue` so batch callbacks can use a higher
         | 
| 11 | 
            +
              priority queue than jobs. [#2200]
         | 
| 12 | 
            +
            - Gracefully recover if someone runs `SCRIPT FLUSH` on Redis. [#2240]
         | 
| 13 | 
            +
            - Ignore errors when attempting `bulk_requeue`, allowing clean shutdown
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            2.0.0
         | 
| 8 16 | 
             
            -----------
         | 
| 9 17 |  | 
| 10 18 | 
             
            - See [the Upgrade Notes](Pro-2.0-Upgrade.md) for detailed notes.
         | 
    
        data/README.md
    CHANGED
    
    | @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            Sidekiq
         | 
| 2 2 | 
             
            ==============
         | 
| 3 3 |  | 
| 4 | 
            -
            [](https://rubygems.org/gems/sidekiq)
         | 
| 5 | 
            +
            [](https://codeclimate.com/github/mperham/sidekiq)
         | 
| 6 | 
            +
            [](https://travis-ci.org/mperham/sidekiq)
         | 
| 7 | 
            +
            [](https://coveralls.io/r/mperham/sidekiq)
         | 
| 8 | 
            +
            [](https://gitter.im/mperham/sidekiq)
         | 
| 9 9 |  | 
| 10 10 |  | 
| 11 11 | 
             
            Simple, efficient background processing for Ruby.
         | 
| @@ -46,7 +46,7 @@ Getting Started | |
| 46 46 | 
             
            -----------------
         | 
| 47 47 |  | 
| 48 48 | 
             
            See the [sidekiq home page](http://sidekiq.org) for the simple 3-step process.
         | 
| 49 | 
            -
            You can watch [Railscast #366](http://railscasts.com/episodes/366-sidekiq) to see Sidekiq in action.  If you do everything right, you should see this: | 
| 49 | 
            +
            You can watch [Railscast #366](http://railscasts.com/episodes/366-sidekiq) to see Sidekiq in action.  If you do everything right, you should see this:
         | 
| 50 50 |  | 
| 51 51 | 
             
            
         | 
| 52 52 |  | 
    
        data/lib/sidekiq/api.rb
    CHANGED
    
    | @@ -218,7 +218,7 @@ module Sidekiq | |
| 218 218 | 
             
                  Time.now.to_f - Sidekiq.load_json(entry)['enqueued_at']
         | 
| 219 219 | 
             
                end
         | 
| 220 220 |  | 
| 221 | 
            -
                def each | 
| 221 | 
            +
                def each
         | 
| 222 222 | 
             
                  initial_size = size
         | 
| 223 223 | 
             
                  deleted_size = 0
         | 
| 224 224 | 
             
                  page = 0
         | 
| @@ -233,14 +233,14 @@ module Sidekiq | |
| 233 233 | 
             
                    break if entries.empty?
         | 
| 234 234 | 
             
                    page += 1
         | 
| 235 235 | 
             
                    entries.each do |entry|
         | 
| 236 | 
            -
                       | 
| 236 | 
            +
                      yield Job.new(entry, @name)
         | 
| 237 237 | 
             
                    end
         | 
| 238 238 | 
             
                    deleted_size = initial_size - size
         | 
| 239 239 | 
             
                  end
         | 
| 240 240 | 
             
                end
         | 
| 241 241 |  | 
| 242 242 | 
             
                def find_job(jid)
         | 
| 243 | 
            -
                   | 
| 243 | 
            +
                  detect { |j| j.jid == jid }
         | 
| 244 244 | 
             
                end
         | 
| 245 245 |  | 
| 246 246 | 
             
                def clear
         | 
| @@ -341,7 +341,7 @@ module Sidekiq | |
| 341 341 | 
             
                def safe_load(content, default)
         | 
| 342 342 | 
             
                  begin
         | 
| 343 343 | 
             
                    yield(*YAML.load(content))
         | 
| 344 | 
            -
                  rescue  | 
| 344 | 
            +
                  rescue => ex
         | 
| 345 345 | 
             
                    # #1761 in dev mode, it's possible to have jobs enqueued which haven't been loaded into
         | 
| 346 346 | 
             
                    # memory yet so the YAML can't be loaded.
         | 
| 347 347 | 
             
                    Sidekiq.logger.warn "Unable to load YAML: #{ex.message}" unless Sidekiq.options[:environment] == 'development'
         | 
| @@ -474,7 +474,7 @@ module Sidekiq | |
| 474 474 | 
             
                  end
         | 
| 475 475 | 
             
                end
         | 
| 476 476 |  | 
| 477 | 
            -
                def each | 
| 477 | 
            +
                def each
         | 
| 478 478 | 
             
                  initial_size = @_size
         | 
| 479 479 | 
             
                  offset_size = 0
         | 
| 480 480 | 
             
                  page = -1
         | 
| @@ -489,7 +489,7 @@ module Sidekiq | |
| 489 489 | 
             
                    break if elements.empty?
         | 
| 490 490 | 
             
                    page -= 1
         | 
| 491 491 | 
             
                    elements.each do |element, score|
         | 
| 492 | 
            -
                       | 
| 492 | 
            +
                      yield SortedEntry.new(self, score, element)
         | 
| 493 493 | 
             
                    end
         | 
| 494 494 | 
             
                    offset_size = initial_size - @_size
         | 
| 495 495 | 
             
                  end
         | 
| @@ -651,7 +651,7 @@ module Sidekiq | |
| 651 651 | 
             
                  count
         | 
| 652 652 | 
             
                end
         | 
| 653 653 |  | 
| 654 | 
            -
                def each | 
| 654 | 
            +
                def each
         | 
| 655 655 | 
             
                  procs = Sidekiq.redis { |conn| conn.smembers('processes') }.sort
         | 
| 656 656 |  | 
| 657 657 | 
             
                  Sidekiq.redis do |conn|
         | 
| @@ -760,7 +760,7 @@ module Sidekiq | |
| 760 760 | 
             
              class Workers
         | 
| 761 761 | 
             
                include Enumerable
         | 
| 762 762 |  | 
| 763 | 
            -
                def each | 
| 763 | 
            +
                def each
         | 
| 764 764 | 
             
                  Sidekiq.redis do |conn|
         | 
| 765 765 | 
             
                    procs = conn.smembers('processes')
         | 
| 766 766 | 
             
                    procs.sort.each do |key|
         | 
    
        data/lib/sidekiq/cli.rb
    CHANGED
    
    
| @@ -28,7 +28,6 @@ module Sidekiq | |
| 28 28 |  | 
| 29 29 | 
             
                  def deliver(msg)
         | 
| 30 30 | 
             
                    if msg.respond_to?(:deliver_now)
         | 
| 31 | 
            -
                      ActiveSupport::Deprecation.warn('`ActionMailer.delay.method` is deprecated. Use `ActionMailer.method.deliver_later` instead and configure ActiveJob to use Sidekiq.')
         | 
| 32 31 | 
             
                      # Rails 4.2/5.0
         | 
| 33 32 | 
             
                      msg.deliver_now
         | 
| 34 33 | 
             
                    else
         | 
    
        data/lib/sidekiq/launcher.rb
    CHANGED
    
    
| @@ -120,11 +120,11 @@ module Sidekiq | |
| 120 120 | 
             
                    entries.clear
         | 
| 121 121 | 
             
                  end
         | 
| 122 122 |  | 
| 123 | 
            -
                  def invoke(*args | 
| 123 | 
            +
                  def invoke(*args)
         | 
| 124 124 | 
             
                    chain = retrieve.dup
         | 
| 125 125 | 
             
                    traverse_chain = lambda do
         | 
| 126 126 | 
             
                      if chain.empty?
         | 
| 127 | 
            -
                         | 
| 127 | 
            +
                        yield
         | 
| 128 128 | 
             
                      else
         | 
| 129 129 | 
             
                        chain.shift.call(*args, &traverse_chain)
         | 
| 130 130 | 
             
                      end
         | 
| @@ -50,7 +50,7 @@ module Sidekiq | |
| 50 50 | 
             
                  #
         | 
| 51 51 | 
             
                  #   Sidekiq.configure_server do |config|
         | 
| 52 52 | 
             
                  #     config.server_middleware do |chain|
         | 
| 53 | 
            -
                  #       chain.add Middleware::Server::RetryJobs, :max_retries => 7
         | 
| 53 | 
            +
                  #       chain.add Sidekiq::Middleware::Server::RetryJobs, :max_retries => 7
         | 
| 54 54 | 
             
                  #     end
         | 
| 55 55 | 
             
                  #   end
         | 
| 56 56 | 
             
                  #
         | 
    
        data/lib/sidekiq/version.rb
    CHANGED
    
    
    
        data/lib/sidekiq/worker.rb
    CHANGED
    
    | @@ -42,13 +42,13 @@ module Sidekiq | |
| 42 42 |  | 
| 43 43 | 
             
                  def perform_in(interval, *args)
         | 
| 44 44 | 
             
                    int = interval.to_f
         | 
| 45 | 
            -
                    now = Time.now | 
| 46 | 
            -
                    ts = (int < 1_000_000_000 ? now +  | 
| 45 | 
            +
                    now = Time.now
         | 
| 46 | 
            +
                    ts = (int < 1_000_000_000 ? (now + interval).to_f : int)
         | 
| 47 47 |  | 
| 48 48 | 
             
                    item = { 'class' => self, 'args' => args, 'at' => ts }
         | 
| 49 49 |  | 
| 50 50 | 
             
                    # Optimization to enqueue something now that is scheduled to go out now or in the past
         | 
| 51 | 
            -
                    item.delete('at'.freeze) if ts <= now
         | 
| 51 | 
            +
                    item.delete('at'.freeze) if ts <= now.to_f
         | 
| 52 52 |  | 
| 53 53 | 
             
                    client_push(item)
         | 
| 54 54 | 
             
                  end
         | 
    
        data/test/test_api.rb
    CHANGED
    
    | @@ -24,7 +24,7 @@ class TestApi < Sidekiq::Test | |
| 24 24 | 
             
                describe "failed" do
         | 
| 25 25 | 
             
                  it "is initially zero" do
         | 
| 26 26 | 
             
                    s = Sidekiq::Stats.new
         | 
| 27 | 
            -
                    assert_equal 0, s. | 
| 27 | 
            +
                    assert_equal 0, s.failed
         | 
| 28 28 | 
             
                  end
         | 
| 29 29 |  | 
| 30 30 | 
             
                  it "returns number of failed jobs" do
         | 
| @@ -311,8 +311,6 @@ class TestApi < Sidekiq::Test | |
| 311 311 | 
             
                  add_retry('bob1', same_time)
         | 
| 312 312 | 
             
                  add_retry('bob2', same_time)
         | 
| 313 313 | 
             
                  r = Sidekiq::RetrySet.new
         | 
| 314 | 
            -
                  # jobs = r.fetch(same_time)
         | 
| 315 | 
            -
                  # puts jobs[1].jid
         | 
| 316 314 | 
             
                  assert_equal 1, r.fetch(same_time, 'bob1').size
         | 
| 317 315 | 
             
                end
         | 
| 318 316 |  | 
    
        data/test/test_scheduling.rb
    CHANGED
    
    | @@ -30,6 +30,15 @@ class TestScheduling < Sidekiq::Test | |
| 30 30 | 
             
                  @redis.verify
         | 
| 31 31 | 
             
                end
         | 
| 32 32 |  | 
| 33 | 
            +
                it 'schedules a job in one month' do
         | 
| 34 | 
            +
                  @redis.expect :zadd, true do |key, args|
         | 
| 35 | 
            +
                    assert_equal 'schedule', key
         | 
| 36 | 
            +
                    assert_in_delta 1.month.since.to_f, args[0][0].to_f, 1
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
                  assert ScheduledWorker.perform_in(1.month, 'mike')
         | 
| 39 | 
            +
                  @redis.verify
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
             | 
| 33 42 | 
             
                it 'schedules a job via timestamp' do
         | 
| 34 43 | 
             
                  @redis.expect :zadd, true, ['schedule', Array]
         | 
| 35 44 | 
             
                  assert ScheduledWorker.perform_in(5.days.from_now, 'mike')
         | 
    
        data/web/views/_footer.erb
    CHANGED
    
    | @@ -6,14 +6,14 @@ | |
| 6 6 | 
             
                        <p class="navbar-text" style="color:white;"><%= product_version %></p>
         | 
| 7 7 | 
             
                      </li>
         | 
| 8 8 | 
             
                      <li>
         | 
| 9 | 
            -
                        <p class="navbar-text">Redis: <%= redis_connection %></p>
         | 
| 9 | 
            +
                        <p class="navbar-text redis-url">Redis: <%= redis_connection %></p>
         | 
| 10 10 | 
             
                      </li>
         | 
| 11 11 | 
             
                      <li>
         | 
| 12 12 | 
             
                        <p class="navbar-text"><%= t('Time') %>: <%= Time.now.utc.strftime('%H:%M:%S UTC') %></p>
         | 
| 13 13 | 
             
                      </li>
         | 
| 14 14 | 
             
                      <% if namespace %>
         | 
| 15 15 | 
             
                          <li>
         | 
| 16 | 
            -
                            <p class="navbar-text"><%= t('Namespace') %>: <%= namespace %></p>
         | 
| 16 | 
            +
                            <p class="navbar-text redis-namespace"><%= t('Namespace') %>: <%= namespace %></p>
         | 
| 17 17 | 
             
                          </li>
         | 
| 18 18 | 
             
                      <% end %>
         | 
| 19 19 | 
             
                    </ul>
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: sidekiq
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.3. | 
| 4 | 
            +
              version: 3.3.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Mike Perham
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2015- | 
| 11 | 
            +
            date: 2015-03-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: redis
         |