que 1.0.0.beta → 1.0.0.beta2
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 +5 -5
- data/CHANGELOG.1.0.beta.md +127 -0
- data/CHANGELOG.md +29 -7
- data/README.md +14 -1
- data/bin/command_line_interface.rb +11 -23
- data/docs/active_job.md +1 -1
- data/docs/command_line_interface.md +3 -3
- data/docs/middleware.md +25 -4
- data/lib/que.rb +9 -4
- data/lib/que/active_record/connection.rb +3 -3
- data/lib/que/active_record/model.rb +3 -3
- data/lib/que/connection.rb +24 -15
- data/lib/que/connection_pool.rb +2 -2
- data/lib/que/job.rb +1 -1
- data/lib/que/{job_cache.rb → job_buffer.rb} +72 -53
- data/lib/que/locker.rb +156 -126
- data/lib/que/poller.rb +1 -1
- data/lib/que/rails/railtie.rb +3 -3
- data/lib/que/result_queue.rb +2 -2
- data/lib/que/utils/constantization.rb +1 -1
- data/lib/que/utils/logging.rb +2 -1
- data/lib/que/utils/middleware.rb +26 -13
- data/lib/que/version.rb +1 -1
- data/lib/que/worker.rb +6 -6
- metadata +5 -4
    
        data/lib/que/poller.rb
    CHANGED
    
    
    
        data/lib/que/rails/railtie.rb
    CHANGED
    
    | @@ -2,12 +2,12 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            module Que
         | 
| 4 4 | 
             
              module Rails
         | 
| 5 | 
            -
                class Railtie < Rails::Railtie
         | 
| 5 | 
            +
                class Railtie < ::Rails::Railtie
         | 
| 6 6 | 
             
                  config.que = Que
         | 
| 7 7 |  | 
| 8 | 
            -
                  Que.run_asynchronously = true if Rails.env.test?
         | 
| 8 | 
            +
                  Que.run_asynchronously = true if ::Rails.env.test?
         | 
| 9 9 |  | 
| 10 | 
            -
                  Que.logger     = proc { Rails.logger }
         | 
| 10 | 
            +
                  Que.logger     = proc { ::Rails.logger }
         | 
| 11 11 | 
             
                  Que.connection = ::ActiveRecord if defined? ::ActiveRecord
         | 
| 12 12 | 
             
                end
         | 
| 13 13 | 
             
              end
         | 
    
        data/lib/que/result_queue.rb
    CHANGED
    
    
    
        data/lib/que/utils/logging.rb
    CHANGED
    
    
    
        data/lib/que/utils/middleware.rb
    CHANGED
    
    | @@ -5,27 +5,40 @@ | |
| 5 5 | 
             
            module Que
         | 
| 6 6 | 
             
              module Utils
         | 
| 7 7 | 
             
                module Middleware
         | 
| 8 | 
            -
                   | 
| 9 | 
            -
                     | 
| 10 | 
            -
             | 
| 11 | 
            -
             | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 8 | 
            +
                  TYPES = [
         | 
| 9 | 
            +
                    :job,
         | 
| 10 | 
            +
                    :sql,
         | 
| 11 | 
            +
                  ].freeze
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  TYPES.each do |type|
         | 
| 14 | 
            +
                    module_eval <<-CODE
         | 
| 15 | 
            +
                      def #{type}_middleware
         | 
| 16 | 
            +
                        @#{type}_middleware ||= []
         | 
| 17 | 
            +
                      end
         | 
| 15 18 |  | 
| 16 | 
            -
             | 
| 17 | 
            -
             | 
| 19 | 
            +
                      def run_#{type}_middleware(*args)
         | 
| 20 | 
            +
                        m = #{type}_middleware
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                        if m.empty?
         | 
| 23 | 
            +
                          yield
         | 
| 24 | 
            +
                        else
         | 
| 25 | 
            +
                          invoke_middleware(middleware: m.dup, args: args) { yield }
         | 
| 26 | 
            +
                        end
         | 
| 27 | 
            +
                      end
         | 
| 28 | 
            +
                    CODE
         | 
| 18 29 | 
             
                  end
         | 
| 19 30 |  | 
| 20 31 | 
             
                  private
         | 
| 21 32 |  | 
| 22 | 
            -
                  def invoke_middleware(middleware:,  | 
| 33 | 
            +
                  def invoke_middleware(middleware:, args:, &block)
         | 
| 23 34 | 
             
                    if m = middleware.shift
         | 
| 24 | 
            -
                       | 
| 25 | 
            -
             | 
| 35 | 
            +
                      r = nil
         | 
| 36 | 
            +
                      m.call(*args) do
         | 
| 37 | 
            +
                        r = invoke_middleware(middleware: middleware, args: args, &block)
         | 
| 26 38 | 
             
                      end
         | 
| 39 | 
            +
                      r
         | 
| 27 40 | 
             
                    else
         | 
| 28 | 
            -
                       | 
| 41 | 
            +
                      yield
         | 
| 29 42 | 
             
                    end
         | 
| 30 43 | 
             
                  end
         | 
| 31 44 | 
             
                end
         | 
    
        data/lib/que/version.rb
    CHANGED
    
    
    
        data/lib/que/worker.rb
    CHANGED
    
    | @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            # frozen_string_literal: true
         | 
| 2 2 |  | 
| 3 | 
            -
            # Workers wrap threads which continuously pull job pks from  | 
| 3 | 
            +
            # Workers wrap threads which continuously pull job pks from JobBuffer objects,
         | 
| 4 4 | 
             
            # fetch and work those jobs, and export relevant data to ResultQueues.
         | 
| 5 5 |  | 
| 6 6 | 
             
            module Que
         | 
| @@ -15,20 +15,20 @@ module Que | |
| 15 15 | 
             
                  }
         | 
| 16 16 |  | 
| 17 17 | 
             
                def initialize(
         | 
| 18 | 
            -
                   | 
| 18 | 
            +
                  job_buffer:,
         | 
| 19 19 | 
             
                  result_queue:,
         | 
| 20 20 | 
             
                  priority: nil,
         | 
| 21 21 | 
             
                  start_callback: nil
         | 
| 22 22 | 
             
                )
         | 
| 23 23 |  | 
| 24 24 | 
             
                  @priority     = Que.assert([NilClass, Integer], priority)
         | 
| 25 | 
            -
                  @ | 
| 25 | 
            +
                  @job_buffer   = Que.assert(JobBuffer, job_buffer)
         | 
| 26 26 | 
             
                  @result_queue = Que.assert(ResultQueue, result_queue)
         | 
| 27 27 |  | 
| 28 28 | 
             
                  Que.internal_log(:worker_instantiate, self) do
         | 
| 29 29 | 
             
                    {
         | 
| 30 30 | 
             
                      priority:     priority,
         | 
| 31 | 
            -
                       | 
| 31 | 
            +
                      job_buffer:   job_buffer.object_id,
         | 
| 32 32 | 
             
                      result_queue: result_queue.object_id,
         | 
| 33 33 | 
             
                    }
         | 
| 34 34 | 
             
                  end
         | 
| @@ -80,7 +80,7 @@ module Que | |
| 80 80 | 
             
                end
         | 
| 81 81 |  | 
| 82 82 | 
             
                def fetch_next_metajob
         | 
| 83 | 
            -
                  @ | 
| 83 | 
            +
                  @job_buffer.shift(*priority)
         | 
| 84 84 | 
             
                end
         | 
| 85 85 |  | 
| 86 86 | 
             
                def work_job(metajob)
         | 
| @@ -89,7 +89,7 @@ module Que | |
| 89 89 | 
             
                  klass    = Que.constantize(job.fetch(:job_class))
         | 
| 90 90 | 
             
                  instance = klass.new(job)
         | 
| 91 91 |  | 
| 92 | 
            -
                  Que. | 
| 92 | 
            +
                  Que.run_job_middleware(instance) { instance.tap(&:_run) }
         | 
| 93 93 |  | 
| 94 94 | 
             
                  log_message = {
         | 
| 95 95 | 
             
                    level: :debug,
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: que
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.0.0. | 
| 4 | 
            +
              version: 1.0.0.beta2
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Chris Hanks
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2018-04-13 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -33,6 +33,7 @@ extensions: [] | |
| 33 33 | 
             
            extra_rdoc_files: []
         | 
| 34 34 | 
             
            files:
         | 
| 35 35 | 
             
            - ".gitignore"
         | 
| 36 | 
            +
            - CHANGELOG.1.0.beta.md
         | 
| 36 37 | 
             
            - CHANGELOG.md
         | 
| 37 38 | 
             
            - LICENSE.txt
         | 
| 38 39 | 
             
            - README.md
         | 
| @@ -62,7 +63,7 @@ files: | |
| 62 63 | 
             
            - lib/que/connection.rb
         | 
| 63 64 | 
             
            - lib/que/connection_pool.rb
         | 
| 64 65 | 
             
            - lib/que/job.rb
         | 
| 65 | 
            -
            - lib/que/ | 
| 66 | 
            +
            - lib/que/job_buffer.rb
         | 
| 66 67 | 
             
            - lib/que/job_methods.rb
         | 
| 67 68 | 
             
            - lib/que/listener.rb
         | 
| 68 69 | 
             
            - lib/que/locker.rb
         | 
| @@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 113 114 | 
             
                  version: 1.3.1
         | 
| 114 115 | 
             
            requirements: []
         | 
| 115 116 | 
             
            rubyforge_project: 
         | 
| 116 | 
            -
            rubygems_version: 2. | 
| 117 | 
            +
            rubygems_version: 2.7.3
         | 
| 117 118 | 
             
            signing_key: 
         | 
| 118 119 | 
             
            specification_version: 4
         | 
| 119 120 | 
             
            summary: A PostgreSQL-based Job Queue
         |