que 2.2.0 → 2.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fd8e2e7b77de787218a646c550cf38fddd52091c91422fdb5813b12fe1af775c
4
- data.tar.gz: e9abc8a607b82db9b0ed925163ed4b21d61f7f2588b1dfd91bf8b558af3fa14c
3
+ metadata.gz: b6ba77a9666d67547e81022c081b95d0ff1087a25d31e8ae2400213e81e54f2d
4
+ data.tar.gz: fe9220bf6fe842fd7b0b401ae37440e9a5f7033d9fa59594ceeb1eff802c7ecb
5
5
  SHA512:
6
- metadata.gz: 55cea89090a9685c5001aba97794e0fa2246362da2b530b02808966e3a4487d07a908ec980d141ad76d59bd04065863fbc097af2ea78acefda110dfdb37cea48
7
- data.tar.gz: 114317905799b63fcc9b4c5180a15f24da03e7937790e6b330d0d67c5a0d7df062c470dd2b8a98426f5ced795b5da6d435a647e9504b66ba669fb72953872f66
6
+ metadata.gz: 96f9ca6172cc8c69055dbd94557cc818aa7bf360437437a3da0ef502ef280b0c9d9b9d4b6f811dcefe06f2f6079902c6b556f8120171ac743f4308bc0063a17f
7
+ data.tar.gz: '039af963aa1d2106c85144067ee6ec6119f6a7bad22f3301b3c018e46c636e8329c25bd8443460706ef41d9822dcee15e8629ac120cb422ba62a681324f127b8'
@@ -7,17 +7,17 @@ jobs:
7
7
  runs-on: ubuntu-latest
8
8
  strategy:
9
9
  matrix:
10
- ruby_version: ['2.7', '3.0', '3.1']
11
- rails_gemfile: ['6.0', '6.1']
10
+ ruby_version: ['2.7', '3.0', '3.1', '3.2']
11
+ rails_gemfile: ['6.0', '6.1', '7.0', '7.1']
12
12
  postgres_version: ['14']
13
13
  include:
14
14
  # Postgres versions
15
- - { ruby_version: '3.1', rails_gemfile: '6.1', postgres_version: '9' }
16
- - { ruby_version: '3.1', rails_gemfile: '6.1', postgres_version: '10' }
17
- - { ruby_version: '3.1', rails_gemfile: '6.1', postgres_version: '11' }
18
- - { ruby_version: '3.1', rails_gemfile: '6.1', postgres_version: '12' }
19
- - { ruby_version: '3.1', rails_gemfile: '6.1', postgres_version: '13' }
20
- - { ruby_version: '3.1', rails_gemfile: '6.1', postgres_version: '14' }
15
+ - { ruby_version: '3.2', rails_gemfile: '7.1', postgres_version: '9' }
16
+ - { ruby_version: '3.2', rails_gemfile: '7.1', postgres_version: '10' }
17
+ - { ruby_version: '3.2', rails_gemfile: '7.1', postgres_version: '11' }
18
+ - { ruby_version: '3.2', rails_gemfile: '7.1', postgres_version: '12' }
19
+ - { ruby_version: '3.2', rails_gemfile: '7.1', postgres_version: '13' }
20
+ - { ruby_version: '3.2', rails_gemfile: '7.1', postgres_version: '14' }
21
21
  exclude: []
22
22
  name: "Test: Ruby ${{ matrix.ruby_version }}, Rails ${{ matrix.rails_gemfile }}, PostgreSQL ${{ matrix.postgres_version }}"
23
23
  services:
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.1
1
+ 3.2.2
data/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  <!-- MarkdownTOC autolink=true -->
4
4
 
5
+ - [2.3.0 \(2023-10-10\)](#230-2023-10-16)
6
+ - [2.2.1 \(2023-04-28\)](#221-2023-04-28)
5
7
  - [2.2.0 \(2022-08-29\)](#220-2022-08-29)
6
8
  - [2.1.0 \(2022-08-25\)](#210-2022-08-25)
7
9
  - [2.0.0 \(2022-08-25\)](#200-2022-08-25)
@@ -56,6 +58,22 @@
56
58
 
57
59
  <!-- /MarkdownTOC -->
58
60
 
61
+ ## 2.3.0 (2023-10-16)
62
+ - **Fixed**:
63
+ + Don't clear `ActiveRecord` connections when `run_synchronously` is enabled [#393](https://github.com/que-rb/que/pull/393)
64
+
65
+ - **Changed**
66
+ + Improve performance of query used by `QueJob#by_job_class` for jobs wrapped by `ActiveJob` [#394](https://github.com/que-rb/que/pull/394)
67
+
68
+ - **Added**
69
+ + Allow `que` to be started without listen/notify [#395](https://github.com/que-rb/que/pull/395)
70
+ + Support Rails 7.1+ [#403](https://github.com/que-rb/que/pull/403)
71
+
72
+ ## 2.2.1 (2023-04-28)
73
+
74
+ - **Fixed**:
75
+ + Fixed support for ActiveJob in Ruby 3.2. [#390](https://github.com/que-rb/que/pull/390)
76
+
59
77
  ## 2.2.0 (2022-08-29)
60
78
 
61
79
  - **Changed**:
data/Dockerfile CHANGED
@@ -1,4 +1,4 @@
1
- FROM ruby:3.1.1-slim-buster@sha256:2ada3e4fe7b1703c9333ad4eb9fc12c1d4d60bce0f981281b2151057e928d9ad AS base
1
+ FROM ruby:3.2.2-slim-buster@sha256:005f0892d160a4f80f8f89116ec15fddc81f296cd4083db9d59accaed125e270 AS base
2
2
 
3
3
  # Install libpq-dev in our base layer, as it's needed in all environments
4
4
  RUN apt-get update \
data/README.md CHANGED
@@ -59,7 +59,7 @@ class CreateQueSchema < ActiveRecord::Migration[6.0]
59
59
  # Whenever you use Que in a migration, always specify the version you're
60
60
  # migrating to. If you're unsure what the current version is, check the
61
61
  # changelog.
62
- Que.migrate!(version: 6)
62
+ Que.migrate!(version: 7)
63
63
  end
64
64
 
65
65
  def down
@@ -191,6 +191,8 @@ These projects are tested to be compatible with Que 1.x:
191
191
  - [que-web](https://github.com/statianzo/que-web) is a Sinatra-based UI for inspecting your job queue.
192
192
  - [que-scheduler](https://github.com/hlascelles/que-scheduler) lets you schedule tasks using a cron style config file.
193
193
  - [que-locks](https://github.com/airhorns/que-locks) lets you lock around job execution for so only one job runs at once for a set of arguments.
194
+ - [que-unique](https://github.com/bambooengineering/que-unique) provides fast in-memory `enqueue` deduping.
195
+ - [que-prometheus](https://github.com/mnbbrown/que-prometheus) exposes Prometheus API endpoints for job, worker, and queue metrics
194
196
 
195
197
  If you have a project that uses or relates to Que, feel free to submit a PR adding it to the list!
196
198
 
data/docker-compose.yml CHANGED
@@ -10,7 +10,7 @@ services:
10
10
  - db
11
11
  volumes:
12
12
  - .:/work
13
- - ruby-3.1.1-gem-cache:/usr/local/bundle
13
+ - ruby-3.2.2-gem-cache:/usr/local/bundle
14
14
  - ~/.docker-rc.d/:/.docker-rc.d/:ro
15
15
  working_dir: /work
16
16
  entrypoint: /work/scripts/docker-entrypoint
@@ -44,4 +44,4 @@ services:
44
44
 
45
45
  volumes:
46
46
  db-data: ~
47
- ruby-3.1.1-gem-cache: ~
47
+ ruby-3.2.2-gem-cache: ~
data/docs/README.md CHANGED
@@ -139,8 +139,8 @@ There are other docs to read if you're using [Sequel](#using-sequel) or [plain P
139
139
  After you've connected Que to the database, you can manage the jobs table. You'll want to migrate to a specific version in a migration file, to ensure that they work the same way even when you upgrade Que in the future:
140
140
 
141
141
  ```ruby
142
- # Update the schema to version #6.
143
- Que.migrate!(version: 6)
142
+ # Update the schema to version #7.
143
+ Que.migrate!(version: 7)
144
144
 
145
145
  # Remove Que's jobs table entirely.
146
146
  Que.migrate!(version: 0)
@@ -553,7 +553,7 @@ require 'que'
553
553
  Sequel.migration do
554
554
  up do
555
555
  Que.connection = self
556
- Que.migrate!(version: 6)
556
+ Que.migrate!(version: 7)
557
557
  end
558
558
  down do
559
559
  Que.connection = self
@@ -10,6 +10,7 @@ module Que
10
10
  def run(*args)
11
11
  raise Error, "Job class #{self.class} didn't define a run() method!"
12
12
  end
13
+ ruby2_keywords(:run) if respond_to?(:ruby2_keywords, true)
13
14
 
14
15
  def perform(*args)
15
16
  args, kwargs = Que.split_out_ruby2_keywords(args)
@@ -31,6 +32,7 @@ module Que
31
32
  ),
32
33
  )
33
34
  end
35
+ ruby2_keywords(:perform) if respond_to?(:ruby2_keywords, true)
34
36
 
35
37
  private
36
38
 
@@ -106,6 +108,41 @@ module Que
106
108
  end
107
109
  end
108
110
 
111
+ # This is the ActiveJob Que adapter for Rails 7.1+, given ActiveJob::QueueAdapters::QueAdapter has been removed from ActiveJob.
112
+ # For backwards compatibility, the class name of ActiveJob::QueueAdapters::QueAdapter::JobWrapper must remain the same, given this string would be in old job records in the database
113
+ if ActiveJob.gem_version >= Gem::Version.new('7.1')
114
+ module ActiveJob
115
+ module QueueAdapters
116
+ # Work around `autoload QueAdapter` being left over in ActiveJob after the adapter was removed
117
+ remove_const(:QueAdapter) if const_defined?(:QueAdapter)
118
+
119
+ class QueAdapter
120
+ def enqueue(job)
121
+ job_options = { priority: job.priority, queue: job.queue_name }
122
+ que_job = JobWrapper.enqueue job.serialize, **job_options
123
+ job.provider_job_id = que_job.attrs["job_id"]
124
+ que_job
125
+ end
126
+
127
+ def enqueue_at(job, timestamp)
128
+ job_options = { priority: job.priority, queue: job.queue_name, run_at: Time.at(timestamp) }
129
+ que_job = JobWrapper.enqueue job.serialize, **job_options
130
+ job.provider_job_id = que_job.attrs["job_id"]
131
+ que_job
132
+ end
133
+
134
+ private
135
+
136
+ class JobWrapper < Que::Job
137
+ def run(job_data)
138
+ Base.execute job_data
139
+ end
140
+ end
141
+ end
142
+ end
143
+ end
144
+ end
145
+
109
146
  class ActiveJob::QueueAdapters::QueAdapter
110
147
  class JobWrapper < Que::Job
111
148
  extend Que::ActiveJob::WrapperExtensions::ClassMethods
@@ -42,7 +42,7 @@ module Que
42
42
  # feature to unknowingly leak connections to other databases. So,
43
43
  # take the additional step of telling ActiveRecord to check in all
44
44
  # of the current thread's connections after each job is run.
45
- ::ActiveRecord::Base.clear_active_connections!
45
+ ::ActiveRecord::Base.clear_active_connections! unless job.class.resolve_que_setting(:run_synchronously)
46
46
  end
47
47
  end
48
48
  end
@@ -25,9 +25,10 @@ module Que
25
25
  class << self
26
26
  def by_job_class(job_class)
27
27
  job_class = job_class.name if job_class.is_a?(Class)
28
+ job_class_doc = "[{\"job_class\": \"#{job_class}\"}]"
28
29
  where(
29
- "que_jobs.job_class = ? OR (que_jobs.job_class = 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper' AND que_jobs.args->0->>'job_class' = ?)",
30
- job_class, job_class,
30
+ "que_jobs.job_class = ? OR (que_jobs.job_class = 'ActiveJob::QueueAdapters::QueAdapter::JobWrapper' AND que_jobs.args @> ?)",
31
+ job_class, job_class_doc,
31
32
  )
32
33
  end
33
34
 
@@ -50,6 +50,14 @@ module Que
50
50
  poll_interval = i
51
51
  end
52
52
 
53
+ opts.on(
54
+ '--listen [LISTEN]',
55
+ String,
56
+ "Set to false to disable listen mode (default: true)"
57
+ ) do |listen|
58
+ options[:listen] = listen != "false"
59
+ end
60
+
53
61
  opts.on(
54
62
  '-l',
55
63
  '--log-level [LEVEL]',
data/lib/que/locker.rb CHANGED
@@ -7,6 +7,10 @@
7
7
  require 'set'
8
8
 
9
9
  module Que
10
+ class << self
11
+ attr_accessor :locker
12
+ end
13
+
10
14
  Listener::MESSAGE_FORMATS[:job_available] =
11
15
  {
12
16
  queue: String,
@@ -71,6 +75,11 @@ module Que
71
75
  Que.assert Array, worker_priorities
72
76
  worker_priorities.each { |p| Que.assert([Integer, NilClass], p) }
73
77
 
78
+ # We assign this globally because we only ever expect one locker to be
79
+ # created per worker process. This can be used by middleware or external
80
+ # code to access the locker during runtime.
81
+ Que.locker = self
82
+
74
83
  # We use a JobBuffer to track jobs and pass them to workers, and a
75
84
  # ResultQueue to receive messages from workers.
76
85
  @job_buffer = JobBuffer.new(
data/lib/que/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Que
4
- VERSION = '2.2.0'
4
+ VERSION = '2.3.0'
5
5
 
6
6
  def self.job_schema_version
7
7
  2
data/lib/que.rb CHANGED
@@ -79,6 +79,10 @@ module Que
79
79
  @default_queue || DEFAULT_QUEUE
80
80
  end
81
81
 
82
+ def server?
83
+ defined?(Que::CommandLineInterface).nil?
84
+ end
85
+
82
86
  # Support simple integration with many common connection pools.
83
87
  def connection=(conn)
84
88
  self.connection_proc =
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: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Hanks
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-29 00:00:00.000000000 Z
11
+ date: 2023-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -115,7 +115,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
115
  - !ruby/object:Gem::Version
116
116
  version: '0'
117
117
  requirements: []
118
- rubygems_version: 3.3.7
118
+ rubygems_version: 3.4.10
119
119
  signing_key:
120
120
  specification_version: 4
121
121
  summary: A PostgreSQL-based Job Queue