workhorse 1.2.13 → 1.2.15
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/CHANGELOG.md +10 -0
- data/README.md +74 -0
- data/VERSION +1 -1
- data/lib/workhorse/active_job_extension.rb +20 -0
- data/lib/workhorse/jobs/run_active_job.rb +6 -0
- data/lib/workhorse/jobs/run_rails_op.rb +4 -0
- data/lib/workhorse/performer.rb +5 -1
- data/lib/workhorse/poller.rb +2 -2
- data/lib/workhorse.rb +1 -0
- data/workhorse.gemspec +4 -4
- metadata +10 -9
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 772b634a73940718f57f2363859977dbc7f20ff4b7c12edada5c4cc499ff5f6c
         | 
| 4 | 
            +
              data.tar.gz: 8c44df6872578300e6577155626f851ae1cb9202653f835b4dabbcc70fd78c70
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 751c63f5b1d86238d3e403332972ea0d177ee6c92acab793f3477d9c68f8223d755c633140e2622c2979b404f369327b6e507303f0d2532e1bcb408edf4a02f6
         | 
| 7 | 
            +
              data.tar.gz: e5209a6b1472239ce48734eb99d0a1c7cfcd9c20d800c6bb5bb77dff001f84ce7b362b444d0d2d3b0ae2b92b035f75d59484df5dc9d4111c7816ad10aa1b17ef
         | 
    
        data/CHANGELOG.md
    CHANGED
    
    | @@ -1,5 +1,15 @@ | |
| 1 1 | 
             
            # Workhorse Changelog
         | 
| 2 2 |  | 
| 3 | 
            +
            ## 1.2.15 - 2023-08-28
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * Add capability to skip transactions for enqueued RailsOps operations.
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            ## 1.2.14 - 2023-08-23
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            * Add documentation for transaction handling.
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * Add support for skipping transactions on a per-job basis
         | 
| 12 | 
            +
             | 
| 3 13 | 
             
            ## 1.2.13 - 2023-02-20
         | 
| 4 14 |  | 
| 5 15 | 
             
            * Add the `config.max_global_lock_fails` setting (defaults to 10). If a
         | 
    
        data/README.md
    CHANGED
    
    | @@ -278,6 +278,80 @@ polling interval. | |
| 278 278 | 
             
            This setting is recommended for all setups and may eventually be enabled by
         | 
| 279 279 | 
             
            default.
         | 
| 280 280 |  | 
| 281 | 
            +
            ## Transactions
         | 
| 282 | 
            +
             | 
| 283 | 
            +
            By default, each job is run in an individual database transaction. An exception
         | 
| 284 | 
            +
            to this is when performing ActiveJob jobs using `perform_now`, where no
         | 
| 285 | 
            +
            transaction is created.
         | 
| 286 | 
            +
             | 
| 287 | 
            +
            ### Transaction callback
         | 
| 288 | 
            +
             | 
| 289 | 
            +
            By default, transactions are created using `ActiveRecord::Base.transaction { ...
         | 
| 290 | 
            +
            }`. You can customize this using the setting `config.tx_callback` in your
         | 
| 291 | 
            +
            `config/initializers/workhorse.rb` (see commented out section in the generated
         | 
| 292 | 
            +
            configuration file).
         | 
| 293 | 
            +
             | 
| 294 | 
            +
            ### Turning off transactions
         | 
| 295 | 
            +
             | 
| 296 | 
            +
            You can turn off transaction wrapping in the following ways:
         | 
| 297 | 
            +
             | 
| 298 | 
            +
            - Globally using the setting `config.perform_jobs_in_tx = false` in your
         | 
| 299 | 
            +
              `config/initializers/workhorse.rb`. This is not recommended as running jobs
         | 
| 300 | 
            +
              without transactions can potentially be harmful.
         | 
| 301 | 
            +
             | 
| 302 | 
            +
            - On a per-job basis. This is the recommended approach for jobs that either open
         | 
| 303 | 
            +
              up their own transaction(s) or jobs that explicitly do not need a transaction
         | 
| 304 | 
            +
              for whatever reason.
         | 
| 305 | 
            +
             | 
| 306 | 
            +
              Usage of this feature depends on whether you are dealing with an ActiveJob
         | 
| 307 | 
            +
              job, an enqueued RailsOps operation or a plain Workhorse job class.
         | 
| 308 | 
            +
             | 
| 309 | 
            +
              For ActiveJob:
         | 
| 310 | 
            +
             | 
| 311 | 
            +
              1. Add the following mixin to your job class (usually `ApplicationJob`):
         | 
| 312 | 
            +
             | 
| 313 | 
            +
                 ```ruby
         | 
| 314 | 
            +
                 class ApplicationJob
         | 
| 315 | 
            +
                   include Workhorse::ActiveJobExtension
         | 
| 316 | 
            +
                 end
         | 
| 317 | 
            +
                 ```
         | 
| 318 | 
            +
             | 
| 319 | 
            +
              2. Use the DSL-method `skip_tx` inside the job classes where you want to
         | 
| 320 | 
            +
                 disable transaction wrapping, e.g.:
         | 
| 321 | 
            +
             | 
| 322 | 
            +
                 ```ruby
         | 
| 323 | 
            +
                 class MyJob < ApplicationJob
         | 
| 324 | 
            +
                   skip_tx
         | 
| 325 | 
            +
             | 
| 326 | 
            +
                   def perform
         | 
| 327 | 
            +
                     # Something without transaction
         | 
| 328 | 
            +
                   end
         | 
| 329 | 
            +
                 end
         | 
| 330 | 
            +
                 ```
         | 
| 331 | 
            +
             | 
| 332 | 
            +
              For enqueuable RailsOps operations:
         | 
| 333 | 
            +
             | 
| 334 | 
            +
              1. Add the following static method to your operation class:
         | 
| 335 | 
            +
             | 
| 336 | 
            +
                 ```ruby
         | 
| 337 | 
            +
                 class MyOp < RailsOps::Operation
         | 
| 338 | 
            +
                   def self.skip_tx?
         | 
| 339 | 
            +
                     true
         | 
| 340 | 
            +
                   end
         | 
| 341 | 
            +
                 end
         | 
| 342 | 
            +
                 ```
         | 
| 343 | 
            +
             | 
| 344 | 
            +
              For plain Workhrose job clases:
         | 
| 345 | 
            +
             | 
| 346 | 
            +
              1. Add the following static method to your job class:
         | 
| 347 | 
            +
             | 
| 348 | 
            +
                 ```ruby
         | 
| 349 | 
            +
                 class MyJob
         | 
| 350 | 
            +
                   def self.skip_tx?
         | 
| 351 | 
            +
                     true
         | 
| 352 | 
            +
                   end
         | 
| 353 | 
            +
                 end
         | 
| 354 | 
            +
             | 
| 281 355 | 
             
            ## Exception handling
         | 
| 282 356 |  | 
| 283 357 | 
             
            Per default, exceptions occurring in a worker thread will only be visible in the
         | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            1.2. | 
| 1 | 
            +
            1.2.15
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            module Workhorse
         | 
| 2 | 
            +
              module ActiveJobExtension
         | 
| 3 | 
            +
                extend ActiveSupport::Concern
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                included do
         | 
| 6 | 
            +
                  class_attribute :_skip_tx
         | 
| 7 | 
            +
                  self._skip_tx = false
         | 
| 8 | 
            +
                end
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                module ClassMethods
         | 
| 11 | 
            +
                  def skip_tx
         | 
| 12 | 
            +
                    self._skip_tx = true
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def skip_tx?
         | 
| 16 | 
            +
                    _skip_tx
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -1,9 +1,15 @@ | |
| 1 1 | 
             
            module Workhorse::Jobs
         | 
| 2 2 | 
             
              class RunActiveJob
         | 
| 3 | 
            +
                attr_reader :job_data
         | 
| 4 | 
            +
             | 
| 3 5 | 
             
                def initialize(job_data)
         | 
| 4 6 | 
             
                  @job_data = job_data
         | 
| 5 7 | 
             
                end
         | 
| 6 8 |  | 
| 9 | 
            +
                def job_class
         | 
| 10 | 
            +
                  @job_data['job_class'].safe_constantize
         | 
| 11 | 
            +
                end
         | 
| 12 | 
            +
             | 
| 7 13 | 
             
                def perform
         | 
| 8 14 | 
             
                  ActiveJob::Base.execute(@job_data)
         | 
| 9 15 | 
             
                end
         | 
    
        data/lib/workhorse/performer.rb
    CHANGED
    
    | @@ -61,7 +61,11 @@ module Workhorse | |
| 61 61 | 
             
                  log 'Performing', :info
         | 
| 62 62 | 
             
                  log "Description: #{@db_job.description}", :info unless @db_job.description.blank?
         | 
| 63 63 |  | 
| 64 | 
            -
                   | 
| 64 | 
            +
                  inner_job_class = deserialized_job.try(:job_class) || deserialized_job.class
         | 
| 65 | 
            +
                  skip_tx = inner_job_class.try(:skip_tx?)
         | 
| 66 | 
            +
                  log "SKIP TX: #{skip_tx.inspect}".red, :error
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                  if Workhorse.perform_jobs_in_tx && !skip_tx
         | 
| 65 69 | 
             
                    Workhorse.tx_callback.call do
         | 
| 66 70 | 
             
                      deserialized_job.perform
         | 
| 67 71 | 
             
                    end
         | 
    
        data/lib/workhorse/poller.rb
    CHANGED
    
    | @@ -111,8 +111,8 @@ module Workhorse | |
| 111 111 | 
             
                                'connection properly. On MySQL, use "show processlist;" to see which connection(s) ' \
         | 
| 112 112 | 
             
                                'is / are holding the lock for a long period of time and consider killing them using '\
         | 
| 113 113 | 
             
                                "MySQL's \"kill <Id>\" command. This message will be issued only once per worker " \
         | 
| 114 | 
            -
                                 | 
| 115 | 
            -
                                 | 
| 114 | 
            +
                                'and may only be re-triggered if the error happens again *after* the lock has ' \
         | 
| 115 | 
            +
                                'been solved in the meantime.'
         | 
| 116 116 |  | 
| 117 117 | 
             
                      worker.log message
         | 
| 118 118 | 
             
                      exception = StandardError.new(message)
         | 
    
        data/lib/workhorse.rb
    CHANGED
    
    
    
        data/workhorse.gemspec
    CHANGED
    
    | @@ -1,15 +1,15 @@ | |
| 1 1 | 
             
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            -
            # stub: workhorse 1.2. | 
| 2 | 
            +
            # stub: workhorse 1.2.15 ruby lib
         | 
| 3 3 |  | 
| 4 4 | 
             
            Gem::Specification.new do |s|
         | 
| 5 5 | 
             
              s.name = "workhorse".freeze
         | 
| 6 | 
            -
              s.version = "1.2. | 
| 6 | 
            +
              s.version = "1.2.15"
         | 
| 7 7 |  | 
| 8 8 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
         | 
| 9 9 | 
             
              s.require_paths = ["lib".freeze]
         | 
| 10 10 | 
             
              s.authors = ["Sitrox".freeze]
         | 
| 11 | 
            -
              s.date = "2023- | 
| 12 | 
            -
              s.files = [".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/detect_stale_jobs_job.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
         | 
| 11 | 
            +
              s.date = "2023-08-28"
         | 
| 12 | 
            +
              s.files = [".github/workflows/ruby.yml".freeze, ".gitignore".freeze, ".releaser_config".freeze, ".rubocop.yml".freeze, "CHANGELOG.md".freeze, "FAQ.md".freeze, "Gemfile".freeze, "LICENSE".freeze, "README.md".freeze, "RUBY_VERSION".freeze, "Rakefile".freeze, "VERSION".freeze, "bin/rubocop".freeze, "lib/active_job/queue_adapters/workhorse_adapter.rb".freeze, "lib/generators/workhorse/install_generator.rb".freeze, "lib/generators/workhorse/templates/bin/workhorse.rb".freeze, "lib/generators/workhorse/templates/config/initializers/workhorse.rb".freeze, "lib/generators/workhorse/templates/create_table_jobs.rb".freeze, "lib/workhorse.rb".freeze, "lib/workhorse/active_job_extension.rb".freeze, "lib/workhorse/daemon.rb".freeze, "lib/workhorse/daemon/shell_handler.rb".freeze, "lib/workhorse/db_job.rb".freeze, "lib/workhorse/enqueuer.rb".freeze, "lib/workhorse/jobs/cleanup_succeeded_jobs.rb".freeze, "lib/workhorse/jobs/detect_stale_jobs_job.rb".freeze, "lib/workhorse/jobs/run_active_job.rb".freeze, "lib/workhorse/jobs/run_rails_op.rb".freeze, "lib/workhorse/performer.rb".freeze, "lib/workhorse/poller.rb".freeze, "lib/workhorse/pool.rb".freeze, "lib/workhorse/scoped_env.rb".freeze, "lib/workhorse/worker.rb".freeze, "test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze, "workhorse.gemspec".freeze]
         | 
| 13 13 | 
             
              s.rubygems_version = "3.0.3".freeze
         | 
| 14 14 | 
             
              s.summary = "Multi-threaded job backend with database queuing for ruby.".freeze
         | 
| 15 15 | 
             
              s.test_files = ["test/active_job/queue_adapters/workhorse_adapter_test.rb".freeze, "test/lib/db_schema.rb".freeze, "test/lib/jobs.rb".freeze, "test/lib/test_helper.rb".freeze, "test/workhorse/db_job_test.rb".freeze, "test/workhorse/enqueuer_test.rb".freeze, "test/workhorse/performer_test.rb".freeze, "test/workhorse/poller_test.rb".freeze, "test/workhorse/pool_test.rb".freeze, "test/workhorse/worker_test.rb".freeze]
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: workhorse
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.2. | 
| 4 | 
            +
              version: 1.2.15
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sitrox
         | 
| 8 | 
            -
            autorequire: | 
| 8 | 
            +
            autorequire:
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2023- | 
| 11 | 
            +
            date: 2023-08-28 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -178,8 +178,8 @@ dependencies: | |
| 178 178 | 
             
                - - ">="
         | 
| 179 179 | 
             
                  - !ruby/object:Gem::Version
         | 
| 180 180 | 
             
                    version: '0'
         | 
| 181 | 
            -
            description: | 
| 182 | 
            -
            email: | 
| 181 | 
            +
            description:
         | 
| 182 | 
            +
            email:
         | 
| 183 183 | 
             
            executables: []
         | 
| 184 184 | 
             
            extensions: []
         | 
| 185 185 | 
             
            extra_rdoc_files: []
         | 
| @@ -203,6 +203,7 @@ files: | |
| 203 203 | 
             
            - lib/generators/workhorse/templates/config/initializers/workhorse.rb
         | 
| 204 204 | 
             
            - lib/generators/workhorse/templates/create_table_jobs.rb
         | 
| 205 205 | 
             
            - lib/workhorse.rb
         | 
| 206 | 
            +
            - lib/workhorse/active_job_extension.rb
         | 
| 206 207 | 
             
            - lib/workhorse/daemon.rb
         | 
| 207 208 | 
             
            - lib/workhorse/daemon/shell_handler.rb
         | 
| 208 209 | 
             
            - lib/workhorse/db_job.rb
         | 
| @@ -227,10 +228,10 @@ files: | |
| 227 228 | 
             
            - test/workhorse/pool_test.rb
         | 
| 228 229 | 
             
            - test/workhorse/worker_test.rb
         | 
| 229 230 | 
             
            - workhorse.gemspec
         | 
| 230 | 
            -
            homepage: | 
| 231 | 
            +
            homepage:
         | 
| 231 232 | 
             
            licenses: []
         | 
| 232 233 | 
             
            metadata: {}
         | 
| 233 | 
            -
            post_install_message: | 
| 234 | 
            +
            post_install_message:
         | 
| 234 235 | 
             
            rdoc_options: []
         | 
| 235 236 | 
             
            require_paths:
         | 
| 236 237 | 
             
            - lib
         | 
| @@ -245,8 +246,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 245 246 | 
             
                - !ruby/object:Gem::Version
         | 
| 246 247 | 
             
                  version: '0'
         | 
| 247 248 | 
             
            requirements: []
         | 
| 248 | 
            -
            rubygems_version: 3. | 
| 249 | 
            -
            signing_key: | 
| 249 | 
            +
            rubygems_version: 3.4.6
         | 
| 250 | 
            +
            signing_key:
         | 
| 250 251 | 
             
            specification_version: 4
         | 
| 251 252 | 
             
            summary: Multi-threaded job backend with database queuing for ruby.
         | 
| 252 253 | 
             
            test_files:
         |