sidekiq-unique-jobs 7.0.0.beta7 → 7.0.0.beta8
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-unique-jobs might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -1
- data/README.md +15 -22
- data/lib/sidekiq_unique_jobs/lock/base_lock.rb +14 -5
- data/lib/sidekiq_unique_jobs/lock/while_executing.rb +1 -1
- data/lib/sidekiq_unique_jobs/lock/while_executing_reject.rb +2 -2
- data/lib/sidekiq_unique_jobs/version.rb +1 -1
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 613b92887d9b07c1e2c0e485a553c3abd9b9586cc3a7026562b20fb1da751459
         | 
| 4 | 
            +
              data.tar.gz: 3638999cdae0b55a4fdc1210ac38aa96782ac139dacb5167692921fd061f7a0f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 613e5e3feeb4e61eee2d2d64a6a648bcef199526b42ad0ef682ead1f91ba6efa8945d01f1ba0379ae5acc4f44e27377ab320990db68822449ab3dab0a4bbb85f
         | 
| 7 | 
            +
              data.tar.gz: 8802925c25b1f32552dcaf6329a90c4c9f825ea828f85c2c7570a2a359fa0cbf20f4102d5908c27e2ea210f671b7ac2b878096a1b6e905222faf5d1e357d3d5c
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,14 @@ | |
| 1 1 | 
             
            # Changelog
         | 
| 2 2 |  | 
| 3 | 
            +
            ## [v7.0.0.beta7](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta7) (2019-11-28)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v7.0.0.beta6...v7.0.0.beta7)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            **Fixed bugs:**
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            - A worker with "While Executing" lock and "Reschedule" strategy is rescheduled forever [\#457](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/457)
         | 
| 10 | 
            +
            - Prevent callbacks from preventing locks [\#460](https://github.com/mhenrixon/sidekiq-unique-jobs/pull/460) ([mhenrixon](https://github.com/mhenrixon))
         | 
| 11 | 
            +
             | 
| 3 12 | 
             
            ## [v7.0.0.beta6](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v7.0.0.beta6) (2019-11-28)
         | 
| 4 13 |  | 
| 5 14 | 
             
            [Full Changelog](https://github.com/mhenrixon/sidekiq-unique-jobs/compare/v6.0.18...v7.0.0.beta6)
         | 
| @@ -760,7 +769,6 @@ | |
| 760 769 |  | 
| 761 770 | 
             
            - Seeing this error with latest version 4.0.12 [\#154](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/154)
         | 
| 762 771 | 
             
            - Unique job showing weird behavior [\#153](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/153)
         | 
| 763 | 
            -
            - perform\_in not working in version 4.0.9 [\#150](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/150)
         | 
| 764 772 |  | 
| 765 773 | 
             
            ## [v4.0.12](https://github.com/mhenrixon/sidekiq-unique-jobs/tree/v4.0.12) (2015-12-15)
         | 
| 766 774 |  | 
| @@ -769,6 +777,7 @@ | |
| 769 777 | 
             
            **Closed issues:**
         | 
| 770 778 |  | 
| 771 779 | 
             
            - Can't schedule a job from another job [\#151](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/151)
         | 
| 780 | 
            +
            - perform\_in not working in version 4.0.9 [\#150](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/150)
         | 
| 772 781 | 
             
            - `unique: until\_and\_while\_executing` not working as expected [\#146](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/146)
         | 
| 773 782 | 
             
            - while\_executing still runs duplicate tasks [\#136](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/136)
         | 
| 774 783 | 
             
            - Version 4 Upgrade [\#133](https://github.com/mhenrixon/sidekiq-unique-jobs/issues/133)
         | 
    
        data/README.md
    CHANGED
    
    | @@ -33,27 +33,15 @@ | |
| 33 33 | 
             
              - [While Executing](#while-executing)
         | 
| 34 34 | 
             
              - [Custom Locks](#custom-locks)
         | 
| 35 35 | 
             
            - [Conflict Strategy](#conflict-strategy)
         | 
| 36 | 
            -
             | 
| 37 | 
            -
             | 
| 38 | 
            -
             | 
| 39 | 
            -
             | 
| 40 | 
            -
             | 
| 41 | 
            -
             | 
| 42 | 
            -
            - [ | 
| 43 | 
            -
             | 
| 44 | 
            -
             | 
| 45 | 
            -
              - [Logging](#logging)
         | 
| 46 | 
            -
              - [Cleanup Dead Locks](#cleanup-dead-locks)
         | 
| 47 | 
            -
              - [Other Sidekiq gems](#other-sidekiq-gems)
         | 
| 48 | 
            -
                - [sidekiq-global_id](#sidekiq-global_id)
         | 
| 49 | 
            -
            - [Debugging](#debugging)
         | 
| 50 | 
            -
              - [Sidekiq Web](#sidekiq-web)
         | 
| 51 | 
            -
                - [Show Locks](#show-locks)
         | 
| 52 | 
            -
                - [Show Lock](#show-lock)
         | 
| 53 | 
            -
            - [Communication](#communication)
         | 
| 54 | 
            -
            - [Testing](#testing)
         | 
| 55 | 
            -
              - [Unique Sidekiq Configuration](#unique-sidekiq-configuration)
         | 
| 56 | 
            -
              - [Uniqueness](#uniqueness)
         | 
| 36 | 
            +
            - [lib/strategies/my_custom_strategy.rb](#libstrategiesmycustomstrategyrb)
         | 
| 37 | 
            +
            - [For rails application](#for-rails-application)
         | 
| 38 | 
            +
            - [config/initializers/sidekiq_unique_jobs.rb](#configinitializerssidekiquniquejobsrb)
         | 
| 39 | 
            +
            - [For other projects, whenever you prefer](#for-other-projects-whenever-you-prefer)
         | 
| 40 | 
            +
            - [this goes in your initializer](#this-goes-in-your-initializer)
         | 
| 41 | 
            +
            - [app/config/routes.rb](#appconfigroutesrb)
         | 
| 42 | 
            +
            - [app/workers/bad_worker.rb](#appworkersbad_workerrb)
         | 
| 43 | 
            +
            - [spec/workers/bad_worker_spec.rb](#specworkersbadworkerspecrb)
         | 
| 44 | 
            +
            - [OR](#or)
         | 
| 57 45 | 
             
            - [Contributing](#contributing)
         | 
| 58 46 | 
             
            - [Contributors](#contributors)
         | 
| 59 47 |  | 
| @@ -415,7 +403,12 @@ Please not that if you try to override a default lock, an `ArgumentError` will b | |
| 415 403 |  | 
| 416 404 | 
             
            Decides how we handle conflict. We can either reject the job to the dead queue or reschedule it. Both are useful for jobs that absolutely need to run and have been configured to use the lock `WhileExecuting` that is used only by the sidekiq server process.
         | 
| 417 405 |  | 
| 418 | 
            -
            The last one is log which can be be used with the lock `UntilExecuted` and `UntilExpired`. Now we write a log entry saying the job could not be pushed because it is a duplicate of another job with the same arguments
         | 
| 406 | 
            +
            The last one is log which can be be used with the lock `UntilExecuted` and `UntilExpired`. Now we write a log entry saying the job could not be pushed because it is a duplicate of another job with the same arguments.
         | 
| 407 | 
            +
             | 
| 408 | 
            +
            It is possible for locks to have different conflict strategy for the client and server. This is useful for `:until_and_while_executing`.
         | 
| 409 | 
            +
             | 
| 410 | 
            +
            ```ruby
         | 
| 411 | 
            +
            sidekiq_options lock: :until_and_while_executing, on_conflict: { client: :log, server: :reject }
         | 
| 419 412 |  | 
| 420 413 | 
             
            ### log
         | 
| 421 414 |  | 
| @@ -29,6 +29,7 @@ module SidekiqUniqueJobs | |
| 29 29 | 
             
                    @redis_pool = redis_pool
         | 
| 30 30 | 
             
                    @attempt    = 0
         | 
| 31 31 | 
             
                    add_uniqueness_when_missing # Used to ease testing
         | 
| 32 | 
            +
                    @lock_config = LockConfig.new(item)
         | 
| 32 33 | 
             
                  end
         | 
| 33 34 |  | 
| 34 35 | 
             
                  #
         | 
| @@ -41,7 +42,6 @@ module SidekiqUniqueJobs | |
| 41 42 | 
             
                  # @yield to the caller when given a block
         | 
| 42 43 | 
             
                  #
         | 
| 43 44 | 
             
                  def lock(&block)
         | 
| 44 | 
            -
                    # TODO: only use replace strategy when server is executing the lock
         | 
| 45 45 | 
             
                    return call_strategy unless (locked_token = locksmith.lock(&block))
         | 
| 46 46 |  | 
| 47 47 | 
             
                    locked_token
         | 
| @@ -100,16 +100,19 @@ module SidekiqUniqueJobs | |
| 100 100 |  | 
| 101 101 | 
             
                  def call_strategy
         | 
| 102 102 | 
             
                    @attempt += 1
         | 
| 103 | 
            -
                     | 
| 103 | 
            +
                    client_strategy.call { lock if replace? }
         | 
| 104 104 | 
             
                  end
         | 
| 105 105 |  | 
| 106 106 | 
             
                  def replace?
         | 
| 107 | 
            -
                     | 
| 107 | 
            +
                    client_strategy.replace? && attempt < 2
         | 
| 108 108 | 
             
                  end
         | 
| 109 109 |  | 
| 110 110 | 
             
                  # @!attribute [r] item
         | 
| 111 111 | 
             
                  #   @return [Hash<String, Object>] the Sidekiq job hash
         | 
| 112 112 | 
             
                  attr_reader :item
         | 
| 113 | 
            +
                  # @!attribute [r] lock_config
         | 
| 114 | 
            +
                  #   @return [LockConfig] a lock configuration
         | 
| 115 | 
            +
                  attr_reader :lock_config
         | 
| 113 116 | 
             
                  # @!attribute [r] redis_pool
         | 
| 114 117 | 
             
                  #   @return [Sidekiq::RedisConnection, ConnectionPool, NilClass] the redis connection
         | 
| 115 118 | 
             
                  attr_reader :redis_pool
         | 
| @@ -135,8 +138,14 @@ module SidekiqUniqueJobs | |
| 135 138 | 
             
                    raise
         | 
| 136 139 | 
             
                  end
         | 
| 137 140 |  | 
| 138 | 
            -
                  def  | 
| 139 | 
            -
                    @ | 
| 141 | 
            +
                  def client_strategy
         | 
| 142 | 
            +
                    @client_strategy ||=
         | 
| 143 | 
            +
                      OnConflict.find_strategy(lock_config.on_client_conflict).new(item, redis_pool)
         | 
| 144 | 
            +
                  end
         | 
| 145 | 
            +
             | 
| 146 | 
            +
                  def server_strategy
         | 
| 147 | 
            +
                    @server_strategy ||=
         | 
| 148 | 
            +
                      OnConflict.find_strategy(lock_config.on_server_conflict).new(item, redis_pool)
         | 
| 140 149 | 
             
                  end
         | 
| 141 150 | 
             
                end
         | 
| 142 151 | 
             
              end
         | 
| @@ -13,8 +13,8 @@ module SidekiqUniqueJobs | |
| 13 13 | 
             
                class WhileExecutingReject < WhileExecuting
         | 
| 14 14 | 
             
                  # Overridden with a forced {OnConflict::Reject} strategy
         | 
| 15 15 | 
             
                  # @return [OnConflict::Reject] a reject strategy
         | 
| 16 | 
            -
                  def  | 
| 17 | 
            -
                    @ | 
| 16 | 
            +
                  def server_strategy
         | 
| 17 | 
            +
                    @server_strategy ||= OnConflict.find_strategy(:reject).new(item, redis_pool)
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                end
         | 
| 20 20 | 
             
              end
         |