que 2.2.1 → 2.4.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 +4 -4
- data/.github/workflows/tests.yml +8 -8
- data/CHANGELOG.md +24 -0
- data/Dockerfile +1 -1
- data/README.md +3 -1
- data/docs/README.md +1 -1
- data/lib/que/active_job/extensions.rb +35 -0
- data/lib/que/active_record/connection.rb +1 -1
- data/lib/que/active_record/model.rb +3 -2
- data/lib/que/command_line_interface.rb +16 -0
- data/lib/que/locker.rb +23 -2
- data/lib/que/version.rb +1 -1
- data/lib/que/worker.rb +2 -2
- data/lib/que.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37c1d6014ec840c445c2142cdd46646409b21d1513bcd1a6d6cea125afe714fb
|
4
|
+
data.tar.gz: bf5215a463ca64b5acee7a6a080296e9dcb39b9fea8399576ad758e63e424edd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 32845cf47073ed8bda56f7bd4594dbd65cceb48324460436437251049fda2548bda517db107034733c5dbbf15edba403111afaf41526ae6a09356aee5b9b93e9
|
7
|
+
data.tar.gz: 791a05612735d7b7480557039001c9d11946b6bffca4f895d44b6a9d58e6c2b78eebb8e20b8440076832e4333e77196f2bb60849fb0f51861ba6572f202d4da7
|
data/.github/workflows/tests.yml
CHANGED
@@ -8,16 +8,16 @@ jobs:
|
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
10
|
ruby_version: ['2.7', '3.0', '3.1', '3.2']
|
11
|
-
rails_gemfile: ['6.0', '6.1', '7.0']
|
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.2', rails_gemfile: '7.
|
16
|
-
- { ruby_version: '3.2', rails_gemfile: '7.
|
17
|
-
- { ruby_version: '3.2', rails_gemfile: '7.
|
18
|
-
- { ruby_version: '3.2', rails_gemfile: '7.
|
19
|
-
- { ruby_version: '3.2', rails_gemfile: '7.
|
20
|
-
- { ruby_version: '3.2', rails_gemfile: '7.
|
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:
|
@@ -45,7 +45,7 @@ jobs:
|
|
45
45
|
run: |
|
46
46
|
sudo apt-get -yqq install libpq-dev postgresql-client
|
47
47
|
createdb que-test
|
48
|
-
gem install bundler
|
48
|
+
gem install bundler --version '~> 2.4.22'
|
49
49
|
bundle install --jobs 4 --retry 3
|
50
50
|
USE_RAILS=true bundle exec rake test
|
51
51
|
bundle exec rake test
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
<!-- MarkdownTOC autolink=true -->
|
4
4
|
|
5
|
+
- [2.4.0 \(2024-08-21\)](#240-2024-08-21)
|
6
|
+
- [2.3.0 \(2023-10-16\)](#230-2023-10-16)
|
5
7
|
- [2.2.1 \(2023-04-28\)](#221-2023-04-28)
|
6
8
|
- [2.2.0 \(2022-08-29\)](#220-2022-08-29)
|
7
9
|
- [2.1.0 \(2022-08-25\)](#210-2022-08-25)
|
@@ -57,6 +59,28 @@
|
|
57
59
|
|
58
60
|
<!-- /MarkdownTOC -->
|
59
61
|
|
62
|
+
## 2.4.0 (2024-08-21)
|
63
|
+
|
64
|
+
- **Fixed**:
|
65
|
+
+ Fixed `Que.server?` method returning the inverse of what was intended. This method can be used to determine whether Que is running as a server process (run from the Que CLI). [#426](https://github.com/que-rb/que/pull/426), context in [#382](https://github.com/que-rb/que/pull/382)
|
66
|
+
- **Added**:
|
67
|
+
+ Added logging of full job details rather than just `job_id`. Note that the hash `Que.log_formatter` is called with no longer contains `:job_id`; instead it now has a `:job` hash including `:id`. [#428](https://github.com/que-rb/que/pull/428)
|
68
|
+
- **Documentation**:
|
69
|
+
+ Improved wording of transaction recommendation in the readme for destroying a job. [#417](https://github.com/que-rb/que/pull/417)
|
70
|
+
+ Added [que-view](https://github.com/kortirso/que-view) to the list of Que-compatible projects in the readme: "A Rails engine-based UI for inspecting your job queue". [#418](https://github.com/que-rb/que/pull/418)
|
71
|
+
|
72
|
+
## 2.3.0 (2023-10-16)
|
73
|
+
|
74
|
+
- **Fixed**:
|
75
|
+
+ Don't clear `ActiveRecord` connections when `run_synchronously` is enabled [#393](https://github.com/que-rb/que/pull/393)
|
76
|
+
|
77
|
+
- **Changed**
|
78
|
+
+ Improve performance of query used by `QueJob#by_job_class` for jobs wrapped by `ActiveJob` [#394](https://github.com/que-rb/que/pull/394)
|
79
|
+
|
80
|
+
- **Added**
|
81
|
+
+ Allow `que` to be started without listen/notify [#395](https://github.com/que-rb/que/pull/395)
|
82
|
+
+ Support Rails 7.1+ [#403](https://github.com/que-rb/que/pull/403)
|
83
|
+
|
60
84
|
## 2.2.1 (2023-04-28)
|
61
85
|
|
62
86
|
- **Fixed**:
|
data/Dockerfile
CHANGED
data/README.md
CHANGED
@@ -92,7 +92,7 @@ class ChargeCreditCard < Que::Job
|
|
92
92
|
|
93
93
|
# It's best to destroy the job in the same transaction as any other
|
94
94
|
# changes you make. Que will mark the job as destroyed for you after the
|
95
|
-
# run method if you don't do it yourself
|
95
|
+
# run method if you don't do it yourself; however if your job writes to the DB
|
96
96
|
# but doesn't destroy the job in the same transaction, it's possible that
|
97
97
|
# the job could be repeated in the event of a crash.
|
98
98
|
destroy
|
@@ -189,9 +189,11 @@ There are a couple ways to do testing. You may want to set `Que::Job.run_synchro
|
|
189
189
|
These projects are tested to be compatible with Que 1.x:
|
190
190
|
|
191
191
|
- [que-web](https://github.com/statianzo/que-web) is a Sinatra-based UI for inspecting your job queue.
|
192
|
+
- [que-view](https://github.com/kortirso/que-view) is a Rails engine-based UI for inspecting your job queue.
|
192
193
|
- [que-scheduler](https://github.com/hlascelles/que-scheduler) lets you schedule tasks using a cron style config file.
|
193
194
|
- [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
195
|
- [que-unique](https://github.com/bambooengineering/que-unique) provides fast in-memory `enqueue` deduping.
|
196
|
+
- [que-prometheus](https://github.com/mnbbrown/que-prometheus) exposes Prometheus API endpoints for job, worker, and queue metrics
|
195
197
|
|
196
198
|
If you have a project that uses or relates to Que, feel free to submit a PR adding it to the list!
|
197
199
|
|
data/docs/README.md
CHANGED
@@ -349,7 +349,7 @@ que --worker-count 1
|
|
349
349
|
By default, Que logs important information in JSON to either Rails' logger (when running in a Rails web process) or STDOUT (when running via the `que` executable). So, your logs will look something like:
|
350
350
|
|
351
351
|
```
|
352
|
-
I, [2017-08-12T05:07:31.094201 #4687] INFO -- : {"lib":"que","hostname":"lovelace","pid":
|
352
|
+
I, [2017-08-12T05:07:31.094201 #4687] INFO -- : {"lib":"que","hostname":"lovelace","pid":98240,"thread":42660,"event":"job_worked","job":{"priority":1,"run_at":"2024-07-24T11:07:10.056514Z","id":2869885284504751564,"job_class":"WorkerJob","error_count":0,"last_error_message":null,"queue":"default","last_error_backtrace":null,"finished_at":null,"expired_at":null,"args":[1],"data":{},"job_schema_version":2,"kwargs":{}},"elapsed":0.001356}
|
353
353
|
```
|
354
354
|
|
355
355
|
Of course you can have it log wherever you like:
|
@@ -108,6 +108,41 @@ module Que
|
|
108
108
|
end
|
109
109
|
end
|
110
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
|
+
|
111
146
|
class ActiveJob::QueueAdapters::QueAdapter
|
112
147
|
class JobWrapper < Que::Job
|
113
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
|
30
|
-
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]',
|
@@ -151,6 +159,14 @@ module Que
|
|
151
159
|
) do |p|
|
152
160
|
options[:wait_period] = p
|
153
161
|
end
|
162
|
+
|
163
|
+
opts.on(
|
164
|
+
'--pidfile [PATH]',
|
165
|
+
String,
|
166
|
+
"Write the PID of this process to the specified file.",
|
167
|
+
) do |p|
|
168
|
+
options[:pidfile] = File.expand_path(p)
|
169
|
+
end
|
154
170
|
end
|
155
171
|
|
156
172
|
parser.parse!(args)
|
data/lib/que/locker.rb
CHANGED
@@ -61,7 +61,8 @@ module Que
|
|
61
61
|
wait_period: DEFAULT_WAIT_PERIOD,
|
62
62
|
maximum_buffer_size: DEFAULT_MAXIMUM_BUFFER_SIZE,
|
63
63
|
worker_priorities: DEFAULT_WORKER_PRIORITIES,
|
64
|
-
on_worker_start: nil
|
64
|
+
on_worker_start: nil,
|
65
|
+
pidfile: nil
|
65
66
|
)
|
66
67
|
|
67
68
|
# Sanity-check all our arguments, since some users may instantiate Locker
|
@@ -215,10 +216,16 @@ module Que
|
|
215
216
|
@connection.wrapped_connection.close
|
216
217
|
end
|
217
218
|
end
|
219
|
+
|
220
|
+
@pidfile = pidfile
|
221
|
+
at_exit { delete_pid }
|
222
|
+
write_pid
|
218
223
|
end
|
219
224
|
|
220
225
|
def stop!
|
221
|
-
stop
|
226
|
+
stop
|
227
|
+
wait_for_stop
|
228
|
+
delete_pid
|
222
229
|
end
|
223
230
|
|
224
231
|
def stop
|
@@ -512,5 +519,19 @@ module Que
|
|
512
519
|
"Tried to lock a job that was already locked: #{id}"
|
513
520
|
end
|
514
521
|
end
|
522
|
+
|
523
|
+
def write_pid
|
524
|
+
return unless @pidfile
|
525
|
+
|
526
|
+
File.open(@pidfile, "w+") do |f|
|
527
|
+
f.write(Process.pid.to_s)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
def delete_pid
|
532
|
+
return unless @pidfile
|
533
|
+
|
534
|
+
File.delete(@pidfile) if File.exist?(@pidfile)
|
535
|
+
end
|
515
536
|
end
|
516
537
|
end
|
data/lib/que/version.rb
CHANGED
data/lib/que/worker.rb
CHANGED
@@ -114,7 +114,7 @@ module Que
|
|
114
114
|
if VALID_LOG_LEVELS.include?(log_level)
|
115
115
|
log_message = {
|
116
116
|
level: log_level,
|
117
|
-
|
117
|
+
job: metajob.job,
|
118
118
|
elapsed: elapsed,
|
119
119
|
}
|
120
120
|
|
@@ -133,7 +133,7 @@ module Que
|
|
133
133
|
Que.log(
|
134
134
|
level: :debug,
|
135
135
|
event: :job_errored,
|
136
|
-
|
136
|
+
job: metajob.job,
|
137
137
|
error: {
|
138
138
|
class: error.class.to_s,
|
139
139
|
message: error.message,
|
data/lib/que.rb
CHANGED
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.
|
4
|
+
version: 2.4.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:
|
11
|
+
date: 2024-08-20 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.
|
118
|
+
rubygems_version: 3.5.7
|
119
119
|
signing_key:
|
120
120
|
specification_version: 4
|
121
121
|
summary: A PostgreSQL-based Job Queue
|