que 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/tests.yml +16 -8
- data/.ruby-version +1 -0
- data/CHANGELOG.md +72 -0
- data/Dockerfile +1 -1
- data/README.md +14 -10
- data/bin/command_line_interface.rb +1 -1
- data/docker-compose.yml +3 -2
- data/docs/README.md +126 -56
- data/lib/que/active_job/extensions.rb +46 -29
- data/lib/que/active_record/model.rb +2 -2
- data/lib/que/connection.rb +1 -1
- data/lib/que/job.rb +14 -32
- data/lib/que/job_methods.rb +6 -2
- data/lib/que/migrations/6/down.sql +8 -0
- data/lib/que/migrations/6/up.sql +8 -0
- data/lib/que/migrations.rb +1 -1
- data/lib/que/sequel/model.rb +5 -2
- data/lib/que/utils/ruby2_keywords.rb +19 -0
- data/lib/que/version.rb +2 -2
- data/lib/que/worker.rb +1 -1
- data/lib/que.rb +2 -0
- data/que.gemspec +2 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c3e59fff6666e5a56dca1724d50cc27d6a0afc1e74c7cb7441ff21363a2cfc1a
|
4
|
+
data.tar.gz: ce13aa6c7b0204ca1e308d7355698f6be752aed5e7303e2eaf14d34780b21ff1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 855c912842adb2097d583a7dc17dd5744b1283ed17e9e21dacc3ebaee238d8d3bc1e1b89e95cf4843cb173d1eb5def298596a53986ee37abaf41f6ab34a109c7
|
7
|
+
data.tar.gz: '09a6a17641f976b708d9c8188c68d70f098faace18de5713df48e6715c4bc2f657a5d83c58773e43d802f531f328b57b604539beb81b18ea22c787a5f116b8a7'
|
data/.github/workflows/tests.yml
CHANGED
@@ -7,11 +7,19 @@ jobs:
|
|
7
7
|
runs-on: ubuntu-latest
|
8
8
|
strategy:
|
9
9
|
matrix:
|
10
|
-
ruby_version: [2.
|
11
|
-
|
12
|
-
postgres_version: [
|
13
|
-
|
14
|
-
|
10
|
+
ruby_version: ['2.7', '3.0', '3.1']
|
11
|
+
rails_gemfile: ['6.0', '6.1']
|
12
|
+
postgres_version: ['14']
|
13
|
+
include:
|
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' }
|
21
|
+
exclude: []
|
22
|
+
name: "Test: Ruby ${{ matrix.ruby_version }}, Rails ${{ matrix.rails_gemfile }}, PostgreSQL ${{ matrix.postgres_version }}"
|
15
23
|
services:
|
16
24
|
db:
|
17
25
|
image: postgres:${{ matrix.postgres_version }}
|
@@ -24,16 +32,16 @@ jobs:
|
|
24
32
|
--health-timeout 5s
|
25
33
|
--health-retries 5
|
26
34
|
steps:
|
27
|
-
- uses: actions/checkout@
|
35
|
+
- uses: actions/checkout@v2
|
28
36
|
- name: Set up Ruby
|
29
|
-
uses:
|
37
|
+
uses: ruby/setup-ruby@v1
|
30
38
|
with:
|
31
39
|
ruby-version: ${{ matrix.ruby_version }}
|
32
40
|
- name: Test with Rake
|
33
41
|
env:
|
34
42
|
PGHOST: 127.0.0.1
|
35
43
|
PGUSER: postgres
|
36
|
-
BUNDLE_GEMFILE: spec/gemfiles/Gemfile
|
44
|
+
BUNDLE_GEMFILE: spec/gemfiles/Gemfile-rails-${{ matrix.rails_gemfile }}
|
37
45
|
run: |
|
38
46
|
sudo apt-get -yqq install libpq-dev postgresql-client
|
39
47
|
createdb que-test
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.1.1
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,9 @@
|
|
2
2
|
|
3
3
|
<!-- MarkdownTOC autolink=true -->
|
4
4
|
|
5
|
+
- [2.0.0 \(2022-08-25\)](#200-2022-08-25)
|
6
|
+
- [1.4.1 \(2022-07-24\)](#141-2022-07-24)
|
7
|
+
- [2.0.0.beta1 \(2022-03-24\)](#200beta1-2022-03-24)
|
5
8
|
- [1.4.0 \(2022-03-23\)](#140-2022-03-23)
|
6
9
|
- [1.3.1 \(2022-02-25\)](#131-2022-02-25)
|
7
10
|
- [1.3.0 \(2022-02-25\)](#130-2022-02-25)
|
@@ -51,6 +54,75 @@
|
|
51
54
|
|
52
55
|
<!-- /MarkdownTOC -->
|
53
56
|
|
57
|
+
## 2.0.0 (2022-08-25)
|
58
|
+
|
59
|
+
See beta 2.0.0.beta1, plus:
|
60
|
+
|
61
|
+
- **Fixed**:
|
62
|
+
+ Updated to use non-deprecated method from PG when params are passed (`#async_exec_params`). [#374](https://github.com/que-rb/que/pull/374)
|
63
|
+
|
64
|
+
Note that @dtcristo submitted a PR proposing an easier upgrade path to Que 2 and Ruby 3 - [#365](https://github.com/que-rb/que/pull/365). We are yet to properly consider this, but a later release which includes this feature would mean you don't need to simultaneously deploy Que 1.x and 2.x workers during the upgrade.
|
65
|
+
|
66
|
+
## 1.4.1 (2022-07-24)
|
67
|
+
|
68
|
+
- **Added**
|
69
|
+
+ Added Ruby version requirement of < 3. For Ruby 3 compatibility, upgrade to Que 2 - [upgrade process](https://github.com/que-rb/que/blob/master/CHANGELOG.md#200beta1-2022-03-24)
|
70
|
+
|
71
|
+
## 2.0.0.beta1 (2022-03-24)
|
72
|
+
|
73
|
+
**Preliminary release of Ruby 3 support**
|
74
|
+
|
75
|
+
**Notable changes**:
|
76
|
+
|
77
|
+
* Support for Ruby 3 introduced
|
78
|
+
* Database schema has changed to split the job arguments `args` column into `args` and `kwargs` columns, for reliable args and kwargs splitting for Ruby 3.
|
79
|
+
- The job schema version is now 2. Note that job schema version is distinct from database schema version and Que version. The `job_schema_version` column of the `que_jobs` table no longer defaults and has a not null constraint, so when manually inserting jobs into the table, this must be specified as `2`. If you have a gem that needs to support multiple Que versions, best not to blindly use the value of `Que.job_schema_version`; instead have different code paths depending on the value of `Que.job_schema_version`. You could also use this to know whether keyword arguments are in `args` or `kwargs`.
|
80
|
+
* Passing a hash literal as the last job argument to be splatted into job keyword arguments is no longer supported.
|
81
|
+
* Dropped support for providing job options as top-level keyword arguments to `Job.enqueue`, i.e. `queue`, `priority`, `run_at`, `job_class`, and `tags`. Job options now need to be nested under the `job_options` keyword argument instead. See [#336](https://github.com/que-rb/que/pull/336)
|
82
|
+
* Dropped support for Ruby < 2.7
|
83
|
+
* Dropped support for Rails < 6.0
|
84
|
+
* The `#by_args` method on the Job model (for both Sequel and ActiveRecord) now searches based on both args and kwargs, but it performs a subset match instead of an exact match. For instance, if your job was scheduled with `'a', 'b', 'c', foo: 'bar', baz: 1`, `by_args('a', 'b', baz: 1)` would find and return the job.
|
85
|
+
* This release contains a database migration. You will need to migrate Que to the latest database schema version (6). For example, on ActiveRecord and Rails 6:
|
86
|
+
|
87
|
+
```ruby
|
88
|
+
class UpdateQueTablesToVersion6 < ActiveRecord::Migration[6.0]
|
89
|
+
def up
|
90
|
+
Que.migrate!(version: 6)
|
91
|
+
end
|
92
|
+
|
93
|
+
def down
|
94
|
+
Que.migrate!(version: 5)
|
95
|
+
end
|
96
|
+
end
|
97
|
+
```
|
98
|
+
|
99
|
+
**Recommended upgrade process**:
|
100
|
+
|
101
|
+
When using Que 2.x, a job enqueued with Ruby 2.7 will run as expected on Ruby 3. We recommend:
|
102
|
+
|
103
|
+
1. Upgrade your project to the latest 1.x version of Que (1.3.1+)
|
104
|
+
- IMPORTANT: adds support for zero downtime upgrade to Que 2.x, see changelog below
|
105
|
+
2. Upgrade your project to Ruby 2.7 and Rails 6.x if it is not already
|
106
|
+
3. Upgrade your project to Que 2.x but stay on Ruby 2.7
|
107
|
+
- IMPORTANT: You will need to continue to run Que 1.x workers until all jobs enqueued using Que 1.x (i.e. with a `job_schema_version` of `1`) have been finished. See below
|
108
|
+
4. Upgrade your project to Ruby 3
|
109
|
+
|
110
|
+
*NOTES:*
|
111
|
+
|
112
|
+
* If you were already running Ruby 2.7 and were not passing a hash literal as the last job argument, you *may* be able to upgrade a running system without draining the queue, though this is not recommended.
|
113
|
+
* For all other cases, you will need to follow the recommended process above or first completely drain the queue (stop enqueuing new jobs and finish processing any jobs in the database, including cleaning out any expired jobs) before upgrading.
|
114
|
+
|
115
|
+
**Deploying Que 1.x and 2.x workers simultaneously**:
|
116
|
+
|
117
|
+
To run workers with two different versions of Que, you'll probably need to temporarily duplicate your gem bundle, with the Que version being the only difference. e.g.:
|
118
|
+
|
119
|
+
- Copy your `Gemfile` and `Gemfile.lock` into a directory called `que-1-gemfile`
|
120
|
+
- Set a suitable Que version in each `Gemfile`
|
121
|
+
- Update the bundle at `que-1-gemfile/Gemfile.lock` using `BUNDLE_GEMFILE=que-1-gemfile/Gemfile bundle`
|
122
|
+
- Create a second deployment of Que, but with your `que` command prefixed with `BUNDLE_GEMFILE=que-1-gemfile/Gemfile`
|
123
|
+
|
124
|
+
We'd appreciate feedback on your experience upgrading to and running Que 2. Feel free to post on our Discord, or if you run into trouble, open an issue on GitHub.
|
125
|
+
|
54
126
|
## 1.4.0 (2022-03-23)
|
55
127
|
|
56
128
|
- **Fixed**
|
data/Dockerfile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
FROM ruby:
|
1
|
+
FROM ruby:3.1.1-slim-buster@sha256:2ada3e4fe7b1703c9333ad4eb9fc12c1d4d60bce0f981281b2151057e928d9ad 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
@@ -1,6 +1,6 @@
|
|
1
1
|
# Que ![tests](https://github.com/que-rb/que/workflows/tests/badge.svg)
|
2
2
|
|
3
|
-
**This README and the rest of the docs on the master branch all refer to Que
|
3
|
+
**This README and the rest of the docs on the master branch all refer to Que 2.x. For older versions, please refer to the docs on the respective branches: [1.x](https://github.com/que-rb/que/tree/1.x), or [0.x](https://github.com/que-rb/que/tree/0.x).**
|
4
4
|
|
5
5
|
*TL;DR: Que is a high-performance job queue that improves the reliability of your application by protecting your jobs with the same [ACID guarantees](https://en.wikipedia.org/wiki/ACID) as the rest of your data.*
|
6
6
|
|
@@ -23,9 +23,9 @@ Que's secondary goal is performance. The worker process is multithreaded, so tha
|
|
23
23
|
|
24
24
|
Compatibility:
|
25
25
|
|
26
|
-
- MRI Ruby 2.2+
|
26
|
+
- MRI Ruby 2.7+ (for Ruby 3, Que 2+ is required)
|
27
27
|
- PostgreSQL 9.5+
|
28
|
-
- Rails
|
28
|
+
- Rails 6.0+ (optional)
|
29
29
|
|
30
30
|
**Please note** - Que's job table undergoes a lot of churn when it is under high load, and like any heavily-written table, is susceptible to bloat and slowness if Postgres isn't able to clean it up. The most common cause of this is long-running transactions, so it's recommended to try to keep all transactions against the database housing Que's job table as short as possible. This is good advice to remember for any high-activity database, but bears emphasizing when using tables that undergo a lot of writes.
|
31
31
|
|
@@ -54,12 +54,12 @@ gem install que
|
|
54
54
|
First, create the queue schema in a migration. For example:
|
55
55
|
|
56
56
|
```ruby
|
57
|
-
class CreateQueSchema < ActiveRecord::Migration[
|
57
|
+
class CreateQueSchema < ActiveRecord::Migration[6.0]
|
58
58
|
def up
|
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:
|
62
|
+
Que.migrate!(version: 6)
|
63
63
|
end
|
64
64
|
|
65
65
|
def down
|
@@ -117,10 +117,14 @@ end
|
|
117
117
|
You can also add options to run the job after a specific time, or with a specific priority:
|
118
118
|
|
119
119
|
```ruby
|
120
|
-
ChargeCreditCard.enqueue
|
120
|
+
ChargeCreditCard.enqueue(card.id, user_id: current_user.id, job_options: { run_at: 1.day.from_now, priority: 5 })
|
121
121
|
```
|
122
|
+
|
123
|
+
[Learn more about job options](docs/README.md#job-options).
|
124
|
+
|
122
125
|
## Running the Que Worker
|
123
|
-
|
126
|
+
|
127
|
+
In order to process jobs, you must start a separate worker process outside of your main server.
|
124
128
|
|
125
129
|
```bash
|
126
130
|
bundle exec que
|
@@ -142,7 +146,7 @@ You may need to pass que a file path to require so that it can load your app. Qu
|
|
142
146
|
|
143
147
|
If you're using ActiveRecord to dump your database's schema, please [set your schema_format to :sql](http://guides.rubyonrails.org/migrations.html#types-of-schema-dumps) so that Que's table structure is managed correctly. This is a good idea regardless, as the `:ruby` schema format doesn't support many of PostgreSQL's advanced features.
|
144
148
|
|
145
|
-
Pre-1.0, the default queue name needed to be configured in order for Que to work out of the box with Rails.
|
149
|
+
Pre-1.0, the default queue name needed to be configured in order for Que to work out of the box with Rails. As of 1.0 the default queue name is now 'default', as Rails expects, but when Rails enqueues some types of jobs it may try to use another queue name that isn't worked by default. You can either:
|
146
150
|
|
147
151
|
- [Configure Rails](https://guides.rubyonrails.org/configuring.html) to send all internal job types to the 'default' queue by adding the following to `config/application.rb`:
|
148
152
|
|
@@ -192,11 +196,11 @@ If you have a project that uses or relates to Que, feel free to submit a PR addi
|
|
192
196
|
|
193
197
|
## Community and Contributing
|
194
198
|
|
195
|
-
- For bugs in the library, please feel free to [open an issue](https://github.com/que-rb/que/issues/new).
|
199
|
+
- For feature suggestions or bugs in the library, please feel free to [open an issue](https://github.com/que-rb/que/issues/new).
|
196
200
|
- For general discussion and questions/concerns that don't relate to obvious bugs, join our [Discord Server](https://discord.gg/B3EW32H).
|
197
201
|
- For contributions, pull requests submitted via Github are welcome.
|
198
202
|
|
199
|
-
Regarding contributions, one of the project's priorities is to keep Que as simple, lightweight and dependency-free as possible, and pull requests that change too much or wouldn't be useful to the majority of Que's users have a good chance of being rejected. If you're thinking of submitting a pull request that adds a new feature, consider starting a discussion in
|
203
|
+
Regarding contributions, one of the project's priorities is to keep Que as simple, lightweight and dependency-free as possible, and pull requests that change too much or wouldn't be useful to the majority of Que's users have a good chance of being rejected. If you're thinking of submitting a pull request that adds a new feature, consider starting a discussion in an issue first about what it would do and how it would be implemented. If it's a sufficiently large feature, or if most of Que's users wouldn't find it useful, it may be best implemented as a standalone gem, like some of the related projects above.
|
200
204
|
|
201
205
|
### Specs
|
202
206
|
|
data/docker-compose.yml
CHANGED
@@ -10,13 +10,14 @@ services:
|
|
10
10
|
- db
|
11
11
|
volumes:
|
12
12
|
- .:/work
|
13
|
-
- ruby-
|
13
|
+
- ruby-3.1.1-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
|
17
17
|
command: bash
|
18
18
|
environment:
|
19
19
|
DATABASE_URL: postgres://que:que@db/que-test
|
20
|
+
USE_RAILS: ~
|
20
21
|
|
21
22
|
db:
|
22
23
|
image: "postgres:${POSTGRES_VERSION-13}"
|
@@ -43,4 +44,4 @@ services:
|
|
43
44
|
|
44
45
|
volumes:
|
45
46
|
db-data: ~
|
46
|
-
ruby-
|
47
|
+
ruby-3.1.1-gem-cache: ~
|
data/docs/README.md
CHANGED
@@ -1,52 +1,62 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# Que documentation
|
2
|
+
|
3
|
+
<!-- MarkdownTOC autolink=true -->
|
3
4
|
|
4
5
|
- [Command Line Interface](#command-line-interface)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
- [`worker-priorities` and `worker-count`](#worker-priorities-and-worker-count)
|
7
|
+
- [`poll-interval`](#poll-interval)
|
8
|
+
- [`maximum-buffer-size`](#maximum-buffer-size)
|
9
|
+
- [`connection-url`](#connection-url)
|
10
|
+
- [`wait-period`](#wait-period)
|
11
|
+
- [`log-internals`](#log-internals)
|
11
12
|
- [Advanced Setup](#advanced-setup)
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
- [Using ActiveRecord Without Rails](#using-activerecord-without-rails)
|
14
|
+
- [Managing the Jobs Table](#managing-the-jobs-table)
|
15
|
+
- [Other Setup](#other-setup)
|
15
16
|
- [Error Handling](#error-handling)
|
16
|
-
|
17
|
-
|
17
|
+
- [Error Notifications](#error-notifications)
|
18
|
+
- [Error-Specific Handling](#error-specific-handling)
|
18
19
|
- [Inspecting the Queue](#inspecting-the-queue)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
- [Job Stats](#job-stats)
|
21
|
+
- [Custom Queries](#custom-queries)
|
22
|
+
- [ActiveRecord Example](#activerecord-example)
|
23
|
+
- [Sequel Example](#sequel-example)
|
23
24
|
- [Managing Workers](#managing-workers)
|
24
|
-
|
25
|
-
|
25
|
+
- [Working Jobs Via Executable](#working-jobs-via-executable)
|
26
|
+
- [Thread-Unsafe Application Code](#thread-unsafe-application-code)
|
26
27
|
- [Logging](#logging)
|
27
|
-
|
28
|
+
- [Logging Job Completion](#logging-job-completion)
|
28
29
|
- [Migrating](#migrating)
|
29
30
|
- [Multiple Queues](#multiple-queues)
|
30
31
|
- [Shutting Down Safely](#shutting-down-safely)
|
31
32
|
- [Using Plain Postgres Connections](#using-plain-postgres-connections)
|
32
|
-
|
33
|
-
|
33
|
+
- [Using ConnectionPool or Pond](#using-connectionpool-or-pond)
|
34
|
+
- [Using Any Other Connection Pool](#using-any-other-connection-pool)
|
34
35
|
- [Using Sequel](#using-sequel)
|
35
36
|
- [Using Que With ActiveJob](#using-que-with-activejob)
|
36
37
|
- [Job Helper Methods](#job-helper-methods)
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
- [`destroy`](#destroy)
|
39
|
+
- [`finish`](#finish)
|
40
|
+
- [`expire`](#expire)
|
41
|
+
- [`retry_in`](#retry_in)
|
42
|
+
- [`error_count`](#error_count)
|
43
|
+
- [`default_resolve_action`](#default_resolve_action)
|
43
44
|
- [Writing Reliable Jobs](#writing-reliable-jobs)
|
44
|
-
|
45
|
+
- [Timeouts](#timeouts)
|
46
|
+
- [Job Options](#job-options)
|
47
|
+
- [`queue`](#queue)
|
48
|
+
- [`priority`](#priority)
|
49
|
+
- [`run_at`](#run_at)
|
50
|
+
- [`job_class`](#job_class)
|
51
|
+
- [`tags`](#tags)
|
45
52
|
- [Middleware](#middleware)
|
46
|
-
|
47
|
-
|
53
|
+
- [Defining Middleware For Jobs](#defining-middleware-for-jobs)
|
54
|
+
- [Defining Middleware For SQL statements](#defining-middleware-for-sql-statements)
|
48
55
|
- [Vacuuming](#vacuuming)
|
56
|
+
- [Expired jobs](#expired-jobs)
|
57
|
+
- [Finished jobs](#finished-jobs)
|
49
58
|
|
59
|
+
<!-- /MarkdownTOC -->
|
50
60
|
|
51
61
|
## Command Line Interface
|
52
62
|
|
@@ -67,7 +77,7 @@ usage: que [options] [file/to/require] ...
|
|
67
77
|
|
68
78
|
Some explanation of the more unusual options:
|
69
79
|
|
70
|
-
### worker-priorities and worker-count
|
80
|
+
### `worker-priorities` and `worker-count`
|
71
81
|
|
72
82
|
These options dictate the size and priority distribution of the worker pool. The default worker-priorities is `10,30,50,any,any,any`. This means that the default worker pool will reserve one worker to only works jobs with priorities under 10, one for priorities under 30, and one for priorities under 50. Three more workers will work any job.
|
73
83
|
|
@@ -77,23 +87,23 @@ Instead of passing worker-priorities, you can pass a `worker-count` - this is a
|
|
77
87
|
|
78
88
|
If you pass both worker-count and worker-priorities, the count will trim or pad the priorities list with `any` workers. So, `--worker-priorities=20,30,40 --worker-count=6` would be the same as passing `--worker-priorities=20,30,40,any,any,any`.
|
79
89
|
|
80
|
-
### poll-interval
|
90
|
+
### `poll-interval`
|
81
91
|
|
82
92
|
This option sets the number of seconds the process will wait between polls of the job queue. Jobs that are ready to be worked immediately will be broadcast via the LISTEN/NOTIFY system, so polling is unnecessary for them - polling is only necessary for jobs that are scheduled in the future or which are being delayed due to errors. The default is 5 seconds.
|
83
93
|
|
84
|
-
### maximum-buffer-size
|
94
|
+
### `maximum-buffer-size`
|
85
95
|
|
86
96
|
This option sets the size of the internal buffer that Que uses to hold jobs until they're ready for workers. The default maximum is 8, meaning that the process won't buffer more than 8 jobs that aren't yet ready to be worked. If you don't want jobs to be buffered at all, you can set this value to zero.
|
87
97
|
|
88
|
-
### connection-url
|
98
|
+
### `connection-url`
|
89
99
|
|
90
100
|
This option sets the URL to be used to open a connection to the database for locking purposes. By default, Que will simply use a connection from the connection pool for locking - this option is only useful if your application connections can't use advisory locks - for example, if they're passed through an external connection pool like PgBouncer. In that case, you'll need to use this option to specify your actual database URL so that Que can establish a direct connection.
|
91
101
|
|
92
|
-
### wait-period
|
102
|
+
### `wait-period`
|
93
103
|
|
94
104
|
This option specifies (in milliseconds) how often the locking thread wakes up to check whether the workers have finished jobs, whether it's time to poll, etc. You shouldn't generally need to tweak this, but it may come in handy for some workloads. The default is 50 milliseconds.
|
95
105
|
|
96
|
-
### log-internals
|
106
|
+
### `log-internals`
|
97
107
|
|
98
108
|
This option instructs Que to output a lot of information about its internal state to the logger. It should only be used if it becomes necessary to debug issues.
|
99
109
|
|
@@ -128,8 +138,8 @@ There are other docs to read if you're using [Sequel](#using-sequel) or [plain P
|
|
128
138
|
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:
|
129
139
|
|
130
140
|
```ruby
|
131
|
-
# Update the schema to version #
|
132
|
-
Que.migrate!(version:
|
141
|
+
# Update the schema to version #6.
|
142
|
+
Que.migrate!(version: 6)
|
133
143
|
|
134
144
|
# Remove Que's jobs table entirely.
|
135
145
|
Que.migrate!(version: 0)
|
@@ -147,7 +157,6 @@ Be sure to read the docs on [managing workers](#managing-workers) for more infor
|
|
147
157
|
|
148
158
|
You'll also want to set up [logging](#logging) and an [error handler](#error-handling) to track errors raised by jobs.
|
149
159
|
|
150
|
-
|
151
160
|
## Error Handling
|
152
161
|
|
153
162
|
If an error is raised and left uncaught by your job, Que will save the error message and backtrace to the database and schedule the job to be retried later.
|
@@ -425,7 +434,6 @@ Que.db_version #=> 3
|
|
425
434
|
|
426
435
|
Note that you can remove Que from your database completely by migrating to version 0.
|
427
436
|
|
428
|
-
|
429
437
|
## Multiple Queues
|
430
438
|
|
431
439
|
Que supports the use of multiple queues in a single job table. Please note that this feature is intended to support the case where multiple codebases are sharing the same job queue - if you want to support jobs of differing priorities, the numeric priority system offers better flexibility and performance.
|
@@ -441,7 +449,7 @@ que -q default -q credit_cards
|
|
441
449
|
Then you can set jobs to be enqueued in that queue specifically:
|
442
450
|
|
443
451
|
```ruby
|
444
|
-
ProcessCreditCard.enqueue
|
452
|
+
ProcessCreditCard.enqueue(current_user.id, job_options: { queue: 'credit_cards' })
|
445
453
|
|
446
454
|
# Or:
|
447
455
|
|
@@ -452,11 +460,7 @@ class ProcessCreditCard < Que::Job
|
|
452
460
|
end
|
453
461
|
```
|
454
462
|
|
455
|
-
In some cases, the ProcessCreditCard class may not be defined in the application that is enqueueing the job. In that case, you can specify the job class as a string
|
456
|
-
|
457
|
-
```ruby
|
458
|
-
Que.enqueue current_user.id, job_class: 'ProcessCreditCard', queue: 'credit_cards'
|
459
|
-
```
|
463
|
+
In some cases, the `ProcessCreditCard` class may not be defined in the application that is enqueueing the job. In that case, you can [specify the job class as a string](#job_class).
|
460
464
|
|
461
465
|
## Shutting Down Safely
|
462
466
|
|
@@ -466,7 +470,6 @@ To prevent this, Que will block the worker process from exiting until all jobs i
|
|
466
470
|
|
467
471
|
So, be prepared to use SIGKILL on your Ruby processes if they run for too long. For example, Heroku takes a good approach to this - when Heroku's platform is shutting down a process, it sends SIGTERM, waits ten seconds, then sends SIGKILL if the process still hasn't exited. This is a nice compromise - it will give each of your currently running jobs ten seconds to complete, and any jobs that haven't finished by then will be interrupted and retried later.
|
468
472
|
|
469
|
-
|
470
473
|
## Using Plain Postgres Connections
|
471
474
|
|
472
475
|
If you're not using an ORM like ActiveRecord or Sequel, you can use a distinct connection pool to manage your Postgres connections. Please be aware that if you **are** using ActiveRecord or Sequel, there's no reason for you to be using any of these methods - it's less efficient (unnecessary connections will waste memory on your database server) and you lose the reliability benefits of wrapping jobs in the same transactions as the rest of your data.
|
@@ -549,7 +552,7 @@ require 'que'
|
|
549
552
|
Sequel.migration do
|
550
553
|
up do
|
551
554
|
Que.connection = self
|
552
|
-
Que.migrate!(version:
|
555
|
+
Que.migrate!(version: 6)
|
553
556
|
end
|
554
557
|
down do
|
555
558
|
Que.connection = self
|
@@ -585,7 +588,7 @@ Sequel automatically wraps model persistance actions (create, update, destroy) i
|
|
585
588
|
|
586
589
|
## Using Que With ActiveJob
|
587
590
|
|
588
|
-
You can include `Que::ActiveJob::JobExtensions` into your `ApplicationJob` subclass to get support for all of Que's
|
591
|
+
You can include `Que::ActiveJob::JobExtensions` into your `ApplicationJob` subclass to get support for all of Que's
|
589
592
|
[helper methods](#job-helper-methods). These methods will become no-ops if you use a queue adapter that isn't Que, so if you like to use a different adapter in development they shouldn't interfere.
|
590
593
|
|
591
594
|
Additionally, including `Que::ActiveJob::JobExtensions` lets you define a run() method that supports keyword arguments.
|
@@ -594,27 +597,29 @@ Additionally, including `Que::ActiveJob::JobExtensions` lets you define a run()
|
|
594
597
|
|
595
598
|
There are a number of instance methods on Que::Job that you can use in your jobs, preferably in transactions. See [Writing Reliable Jobs](#writing-reliable-jobs) for more information on where to use these methods.
|
596
599
|
|
597
|
-
### destroy
|
600
|
+
### `destroy`
|
598
601
|
|
599
602
|
This method deletes the job from the queue table, ensuring that it won't be worked a second time.
|
600
603
|
|
601
|
-
### finish
|
604
|
+
### `finish`
|
602
605
|
|
603
606
|
This method marks the current job as finished, ensuring that it won't be worked a second time. This is like destroy, in that it finalizes a job, but this method leaves the job in the table, in case you want to query it later.
|
604
607
|
|
605
|
-
### expire
|
608
|
+
### `expire`
|
606
609
|
|
607
610
|
This method marks the current job as expired. It will be left in the table and won't be retried, but it will be easy to query for expired jobs. This method is called if the job exceeds its maximum_retry_count.
|
608
611
|
|
609
|
-
### retry_in
|
612
|
+
### `retry_in`
|
610
613
|
|
611
614
|
This method marks the current job to be retried later. You can pass a numeric to this method, in which case that is the number of seconds after which it can be retried (`retry_in(10)`, `retry_in(0.5)`), or, if you're using ActiveSupport, you can pass in a duration object (`retry_in(10.minutes)`). This automatically happens, with an exponentially-increasing interval, when the job encounters an error.
|
612
615
|
|
613
|
-
|
616
|
+
Note that `retry_in` increments the job's `error_count`.
|
617
|
+
|
618
|
+
### `error_count`
|
614
619
|
|
615
620
|
This method returns the total number of times the job has errored, in case you want to modify the job's behavior after it has failed a given number of times.
|
616
621
|
|
617
|
-
### default_resolve_action
|
622
|
+
### `default_resolve_action`
|
618
623
|
|
619
624
|
If you don't perform a resolve action (destroy, finish, expire, retry_in) while the job is worked, Que will call this method for you. By default it simply calls `destroy`, but you can override it in your Job subclasses if you wish - for example, to call `finish`, or to invoke some more complicated logic.
|
620
625
|
|
@@ -727,6 +732,51 @@ end
|
|
727
732
|
|
728
733
|
Now, if the request takes more than five seconds, an error will be raised (probably - check your library's documentation) and Que will just retry the job later.
|
729
734
|
|
735
|
+
## Job Options
|
736
|
+
|
737
|
+
When enqueueing a job, you can specify particular options for it in a `job_options` hash, e.g.:
|
738
|
+
|
739
|
+
```ruby
|
740
|
+
ChargeCreditCard.enqueue(card.id, user_id: current_user.id, job_options: { run_at: 1.day.from_now, priority: 5 })
|
741
|
+
```
|
742
|
+
|
743
|
+
### `queue`
|
744
|
+
|
745
|
+
See [Multiple Queues](#multiple-queues).
|
746
|
+
|
747
|
+
### `priority`
|
748
|
+
|
749
|
+
Provide an integer to customise the priority level of the job.
|
750
|
+
|
751
|
+
We use the Linux priority scale - a lower number is more important.
|
752
|
+
|
753
|
+
### `run_at`
|
754
|
+
|
755
|
+
Provide a `Time` as the `run_at` to make a job run at a later time (well, at some point after it, depending on how busy the workers are).
|
756
|
+
|
757
|
+
It's best not to use `Time.now` here, as the current time in the Ruby process and the database won't be perfectly aligned. When the database considers the `run_at` to be in the past, the job will not be broadcast via the LISTEN/NOTIFY system, and it will need to wait for a poll. This introduces an unnecessary delay of probably a few seconds (depending on your configured [poll interval](#poll-interval)). So if you want the job to run ASAP, just omit the `run_at` option.
|
758
|
+
|
759
|
+
### `job_class`
|
760
|
+
|
761
|
+
Specifying `job_class` allows you to enqueue a job using `Que.enqueue`:
|
762
|
+
|
763
|
+
```ruby
|
764
|
+
Que.enqueue(current_user.id, job_options: { job_class: 'ProcessCreditCard' })
|
765
|
+
```
|
766
|
+
|
767
|
+
Rather than needing to use the job class (nor even have it defined in the enqueueing process):
|
768
|
+
|
769
|
+
```ruby
|
770
|
+
ProcessCreditCard.enqueue(current_user.id)
|
771
|
+
```
|
772
|
+
|
773
|
+
### `tags`
|
774
|
+
|
775
|
+
You can provide an array of strings to give a job some tags. These are not used by Que and are completely custom.
|
776
|
+
|
777
|
+
A job can have up to five tags, each one up to 100 characters long.
|
778
|
+
|
779
|
+
Note that unlike the other job options, tags are stored within the `que_jobs.data` column, rather than a correspondingly-named column.
|
730
780
|
|
731
781
|
## Middleware
|
732
782
|
|
@@ -785,3 +835,23 @@ class ManualVacuumJob < CronJob
|
|
785
835
|
end
|
786
836
|
end
|
787
837
|
```
|
838
|
+
|
839
|
+
## Expired jobs
|
840
|
+
|
841
|
+
Expired jobs hang around in the `que_jobs` table. If necessary, you can get an expired job to run again by clearing the `error_count` and `expired_at` columns, e.g.:
|
842
|
+
|
843
|
+
```sql
|
844
|
+
UPDATE que_jobs SET error_count = 0, expired_at = NULL WHERE id = 172340879;
|
845
|
+
```
|
846
|
+
|
847
|
+
## Finished jobs
|
848
|
+
|
849
|
+
If you prefer to leave finished jobs in the database for a while, to performantly remove them periodically, you can use something like:
|
850
|
+
|
851
|
+
```sql
|
852
|
+
BEGIN;
|
853
|
+
ALTER TABLE que_jobs DISABLE TRIGGER que_state_notify;
|
854
|
+
DELETE FROM que_jobs WHERE finished_at < (select now() - interval '7 days');
|
855
|
+
ALTER TABLE que_jobs ENABLE TRIGGER que_state_notify;
|
856
|
+
COMMIT;
|
857
|
+
```
|
@@ -12,8 +12,10 @@ module Que
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def perform(*args)
|
15
|
+
args, kwargs = Que.split_out_ruby2_keywords(args)
|
16
|
+
|
15
17
|
Que.internal_log(:active_job_perform, self) do
|
16
|
-
{args: args}
|
18
|
+
{args: args, kwargs: kwargs}
|
17
19
|
end
|
18
20
|
|
19
21
|
_run(
|
@@ -21,7 +23,12 @@ module Que
|
|
21
23
|
que_filter_args(
|
22
24
|
args.map { |a| a.is_a?(Hash) ? a.deep_symbolize_keys : a }
|
23
25
|
)
|
24
|
-
)
|
26
|
+
),
|
27
|
+
kwargs: Que.recursively_freeze(
|
28
|
+
que_filter_args(
|
29
|
+
kwargs.deep_symbolize_keys,
|
30
|
+
)
|
31
|
+
),
|
25
32
|
)
|
26
33
|
end
|
27
34
|
|
@@ -53,37 +60,46 @@ module Que
|
|
53
60
|
# A module that we mix into ActiveJob's wrapper for Que::Job, to maintain
|
54
61
|
# backwards-compatibility with internal changes we make.
|
55
62
|
module WrapperExtensions
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
63
|
+
module ClassMethods
|
64
|
+
# We've dropped support for job options supplied as top-level keywords, but ActiveJob's QueAdapter still uses them. So we have to move them into the job_options hash ourselves.
|
65
|
+
def enqueue(args, priority:, queue:, run_at: nil)
|
66
|
+
super(args, job_options: { priority: priority, queue: queue, run_at: run_at })
|
67
|
+
end
|
61
68
|
end
|
62
69
|
|
63
|
-
|
64
|
-
#
|
65
|
-
#
|
66
|
-
#
|
67
|
-
|
68
|
-
|
70
|
+
module InstanceMethods
|
71
|
+
# The Rails adapter (built against a pre-1.0 version of this gem)
|
72
|
+
# assumes that it can access a job's id via job.attrs["job_id"]. So,
|
73
|
+
# oblige it.
|
74
|
+
def attrs
|
75
|
+
{"job_id" => que_attrs[:id]}
|
76
|
+
end
|
77
|
+
|
78
|
+
def run(args)
|
79
|
+
# Our ActiveJob extensions expect to be able to operate on the actual
|
80
|
+
# job object, but there's no way to access it through ActiveJob. So,
|
81
|
+
# scope it to the current thread. It's a bit messy, but it's the best
|
82
|
+
# option under the circumstances (doesn't require hacking ActiveJob in
|
83
|
+
# any more extensive way).
|
69
84
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
85
|
+
# There's no reason this logic should ever nest, because it wouldn't
|
86
|
+
# make sense to run a worker inside of a job, but even so, assert that
|
87
|
+
# nothing absurd is going on.
|
88
|
+
Que.assert NilClass, Thread.current[:que_current_job]
|
74
89
|
|
75
|
-
|
76
|
-
|
90
|
+
begin
|
91
|
+
Thread.current[:que_current_job] = self
|
77
92
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
93
|
+
# We symbolize the args hash but ActiveJob doesn't like that :/
|
94
|
+
super(args.deep_stringify_keys)
|
95
|
+
ensure
|
96
|
+
# Also assert that the current job state was only removed now, but
|
97
|
+
# unset the job first so that an assertion failure doesn't mess up
|
98
|
+
# the state any more than it already has.
|
99
|
+
current = Thread.current[:que_current_job]
|
100
|
+
Thread.current[:que_current_job] = nil
|
101
|
+
Que.assert(self, current)
|
102
|
+
end
|
87
103
|
end
|
88
104
|
end
|
89
105
|
end
|
@@ -92,6 +108,7 @@ end
|
|
92
108
|
|
93
109
|
class ActiveJob::QueueAdapters::QueAdapter
|
94
110
|
class JobWrapper < Que::Job
|
95
|
-
|
111
|
+
extend Que::ActiveJob::WrapperExtensions::ClassMethods
|
112
|
+
prepend Que::ActiveJob::WrapperExtensions::InstanceMethods
|
96
113
|
end
|
97
114
|
end
|
@@ -39,8 +39,8 @@ module Que
|
|
39
39
|
where("que_jobs.data @> ?", JSON.dump(tags: [tag]))
|
40
40
|
end
|
41
41
|
|
42
|
-
def by_args(*args)
|
43
|
-
where("que_jobs.args @> ?", JSON.dump(args))
|
42
|
+
def by_args(*args, **kwargs)
|
43
|
+
where("que_jobs.args @> ? AND que_jobs.kwargs @> ?", JSON.dump(args), JSON.dump(kwargs))
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
data/lib/que/connection.rb
CHANGED
data/lib/que/job.rb
CHANGED
@@ -12,7 +12,7 @@ module Que
|
|
12
12
|
SQL[:insert_job] =
|
13
13
|
%{
|
14
14
|
INSERT INTO public.que_jobs
|
15
|
-
(queue, priority, run_at, job_class, args, data, job_schema_version)
|
15
|
+
(queue, priority, run_at, job_class, args, kwargs, data, job_schema_version)
|
16
16
|
VALUES
|
17
17
|
(
|
18
18
|
coalesce($1, 'default')::text,
|
@@ -21,6 +21,7 @@ module Que
|
|
21
21
|
$4::text,
|
22
22
|
coalesce($5, '[]')::jsonb,
|
23
23
|
coalesce($6, '{}')::jsonb,
|
24
|
+
coalesce($7, '{}')::jsonb,
|
24
25
|
#{Que.job_schema_version}
|
25
26
|
)
|
26
27
|
RETURNING *
|
@@ -56,13 +57,10 @@ module Que
|
|
56
57
|
:priority,
|
57
58
|
:run_at
|
58
59
|
|
59
|
-
def enqueue(
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
)
|
64
|
-
arg_opts, job_options = _extract_job_options(arg_opts, job_options.dup)
|
65
|
-
args << arg_opts if arg_opts.any?
|
60
|
+
def enqueue(*args)
|
61
|
+
args, kwargs = Que.split_out_ruby2_keywords(args)
|
62
|
+
|
63
|
+
job_options = kwargs.delete(:job_options) || {}
|
66
64
|
|
67
65
|
if job_options[:tags]
|
68
66
|
if job_options[:tags].length > MAXIMUM_TAGS_COUNT
|
@@ -81,6 +79,7 @@ module Que
|
|
81
79
|
priority: job_options[:priority] || resolve_que_setting(:priority),
|
82
80
|
run_at: job_options[:run_at] || resolve_que_setting(:run_at),
|
83
81
|
args: Que.serialize_json(args),
|
82
|
+
kwargs: Que.serialize_json(kwargs),
|
84
83
|
data: job_options[:tags] ? Que.serialize_json(tags: job_options[:tags]) : "{}",
|
85
84
|
job_class: \
|
86
85
|
job_options[:job_class] || name ||
|
@@ -89,27 +88,31 @@ module Que
|
|
89
88
|
|
90
89
|
if attrs[:run_at].nil? && resolve_que_setting(:run_synchronously)
|
91
90
|
attrs[:args] = Que.deserialize_json(attrs[:args])
|
91
|
+
attrs[:kwargs] = Que.deserialize_json(attrs[:kwargs])
|
92
92
|
attrs[:data] = Que.deserialize_json(attrs[:data])
|
93
93
|
_run_attrs(attrs)
|
94
94
|
else
|
95
95
|
values =
|
96
96
|
Que.execute(
|
97
97
|
:insert_job,
|
98
|
-
attrs.values_at(:queue, :priority, :run_at, :job_class, :args, :data),
|
98
|
+
attrs.values_at(:queue, :priority, :run_at, :job_class, :args, :kwargs, :data),
|
99
99
|
).first
|
100
|
-
|
101
100
|
new(values)
|
102
101
|
end
|
103
102
|
end
|
103
|
+
ruby2_keywords(:enqueue) if respond_to?(:ruby2_keywords, true)
|
104
104
|
|
105
105
|
def run(*args)
|
106
106
|
# Make sure things behave the same as they would have with a round-trip
|
107
107
|
# to the DB.
|
108
|
+
args, kwargs = Que.split_out_ruby2_keywords(args)
|
108
109
|
args = Que.deserialize_json(Que.serialize_json(args))
|
110
|
+
kwargs = Que.deserialize_json(Que.serialize_json(kwargs))
|
109
111
|
|
110
112
|
# Should not fail if there's no DB connection.
|
111
|
-
_run_attrs(args: args)
|
113
|
+
_run_attrs(args: args, kwargs: kwargs)
|
112
114
|
end
|
115
|
+
ruby2_keywords(:run) if respond_to?(:ruby2_keywords, true)
|
113
116
|
|
114
117
|
def resolve_que_setting(setting, *args)
|
115
118
|
value = send(setting) if respond_to?(setting)
|
@@ -136,27 +139,6 @@ module Que
|
|
136
139
|
end
|
137
140
|
end
|
138
141
|
end
|
139
|
-
|
140
|
-
def _extract_job_options(arg_opts, job_options)
|
141
|
-
deprecated_job_option_names = []
|
142
|
-
|
143
|
-
%i[queue priority run_at job_class tags].each do |option_name|
|
144
|
-
next unless arg_opts.key?(option_name) && job_options[option_name].nil?
|
145
|
-
|
146
|
-
job_options[option_name] = arg_opts.delete(option_name)
|
147
|
-
deprecated_job_option_names << option_name
|
148
|
-
end
|
149
|
-
|
150
|
-
_log_job_options_deprecation(deprecated_job_option_names)
|
151
|
-
|
152
|
-
[arg_opts, job_options]
|
153
|
-
end
|
154
|
-
|
155
|
-
def _log_job_options_deprecation(deprecated_job_option_names)
|
156
|
-
return unless deprecated_job_option_names.any?
|
157
|
-
|
158
|
-
warn "Passing job options like (#{deprecated_job_option_names.join(', ')}) to `JobClass.enqueue` as top level keyword args has been deprecated and will be removed in version 2.0. Please wrap job options in an explicit `job_options` keyword arg instead."
|
159
|
-
end
|
160
142
|
end
|
161
143
|
|
162
144
|
# Set up some defaults.
|
data/lib/que/job_methods.rb
CHANGED
@@ -39,12 +39,16 @@ module Que
|
|
39
39
|
# Run the job with error handling and cleanup logic. Optionally support
|
40
40
|
# overriding the args, because it's necessary when jobs are invoked from
|
41
41
|
# ActiveJob.
|
42
|
-
def _run(args: nil, reraise_errors: false)
|
42
|
+
def _run(args: nil, kwargs: nil, reraise_errors: false)
|
43
43
|
if args.nil? && que_target
|
44
44
|
args = que_target.que_attrs.fetch(:args)
|
45
45
|
end
|
46
46
|
|
47
|
-
|
47
|
+
if kwargs.nil? && que_target
|
48
|
+
kwargs = que_target.que_attrs.fetch(:kwargs)
|
49
|
+
end
|
50
|
+
|
51
|
+
run(*args, **kwargs)
|
48
52
|
default_resolve_action if que_target && !que_target.que_resolved
|
49
53
|
rescue => error
|
50
54
|
raise error unless que_target
|
@@ -0,0 +1,8 @@
|
|
1
|
+
DROP INDEX que_jobs_kwargs_gin_idx;
|
2
|
+
ALTER TABLE que_jobs DROP COLUMN kwargs;
|
3
|
+
|
4
|
+
ALTER INDEX que_poll_idx RENAME TO que_poll_idx_with_job_schema_version;
|
5
|
+
CREATE INDEX que_poll_idx ON que_jobs (queue, priority, run_at, id) WHERE (finished_at IS NULL AND expired_at IS NULL);
|
6
|
+
|
7
|
+
ALTER TABLE que_jobs ALTER COLUMN job_schema_version SET DEFAULT 1;
|
8
|
+
ALTER TABLE que_jobs ALTER COLUMN job_schema_version DROP NOT NULL;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
ALTER TABLE que_jobs ADD COLUMN kwargs JSONB NOT NULL DEFAULT '{}';
|
2
|
+
CREATE INDEX que_jobs_kwargs_gin_idx ON que_jobs USING gin (kwargs jsonb_path_ops);
|
3
|
+
|
4
|
+
DROP INDEX que_poll_idx;
|
5
|
+
ALTER INDEX que_poll_idx_with_job_schema_version RENAME TO que_poll_idx;
|
6
|
+
|
7
|
+
ALTER TABLE que_jobs ALTER COLUMN job_schema_version DROP DEFAULT;
|
8
|
+
ALTER TABLE que_jobs ALTER COLUMN job_schema_version SET NOT NULL;
|
data/lib/que/migrations.rb
CHANGED
data/lib/que/sequel/model.rb
CHANGED
@@ -40,8 +40,11 @@ module Que
|
|
40
40
|
where(QUALIFIED_TABLE[:data].pg_jsonb.contains(JSON.dump(tags: [tag])))
|
41
41
|
end
|
42
42
|
|
43
|
-
def by_args(*args)
|
44
|
-
where(
|
43
|
+
def by_args(*args, **kwargs)
|
44
|
+
where(
|
45
|
+
QUALIFIED_TABLE[:args].pg_jsonb.contains(JSON.dump(args)) &
|
46
|
+
QUALIFIED_TABLE[:kwargs].pg_jsonb.contains(JSON.dump(kwargs))
|
47
|
+
)
|
45
48
|
end
|
46
49
|
end
|
47
50
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Temporary module allowing ruby2 keyword args to be extracted from an *args splat
|
4
|
+
# Allows us to ensure consistent behaviour when running on ruby 2 vs ruby 3
|
5
|
+
# We can remove this if/when we drop support for ruby 2
|
6
|
+
|
7
|
+
require 'json'
|
8
|
+
|
9
|
+
module Que
|
10
|
+
module Utils
|
11
|
+
module Ruby2Keywords
|
12
|
+
def split_out_ruby2_keywords(args)
|
13
|
+
return [args, {}] unless args.last&.is_a?(Hash) && Hash.ruby2_keywords_hash?(args.last)
|
14
|
+
|
15
|
+
[args[0..-2], args.last]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/que/version.rb
CHANGED
data/lib/que/worker.rb
CHANGED
data/lib/que.rb
CHANGED
@@ -29,6 +29,7 @@ module Que
|
|
29
29
|
require_relative 'que/utils/logging'
|
30
30
|
require_relative 'que/utils/middleware'
|
31
31
|
require_relative 'que/utils/queue_management'
|
32
|
+
require_relative 'que/utils/ruby2_keywords'
|
32
33
|
require_relative 'que/utils/transactions'
|
33
34
|
|
34
35
|
require_relative 'que/version'
|
@@ -61,6 +62,7 @@ module Que
|
|
61
62
|
include Utils::Logging
|
62
63
|
include Utils::Middleware
|
63
64
|
include Utils::QueueManagement
|
65
|
+
include Utils::Ruby2Keywords
|
64
66
|
include Utils::Transactions
|
65
67
|
|
66
68
|
extend Forwardable
|
data/que.gemspec
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:
|
4
|
+
version: 2.0.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-
|
11
|
+
date: 2022-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -34,6 +34,7 @@ extra_rdoc_files: []
|
|
34
34
|
files:
|
35
35
|
- ".github/workflows/tests.yml"
|
36
36
|
- ".gitignore"
|
37
|
+
- ".ruby-version"
|
37
38
|
- CHANGELOG.md
|
38
39
|
- Dockerfile
|
39
40
|
- LICENSE.txt
|
@@ -71,6 +72,8 @@ files:
|
|
71
72
|
- lib/que/migrations/4/up.sql
|
72
73
|
- lib/que/migrations/5/down.sql
|
73
74
|
- lib/que/migrations/5/up.sql
|
75
|
+
- lib/que/migrations/6/down.sql
|
76
|
+
- lib/que/migrations/6/up.sql
|
74
77
|
- lib/que/poller.rb
|
75
78
|
- lib/que/rails/railtie.rb
|
76
79
|
- lib/que/result_queue.rb
|
@@ -84,6 +87,7 @@ files:
|
|
84
87
|
- lib/que/utils/logging.rb
|
85
88
|
- lib/que/utils/middleware.rb
|
86
89
|
- lib/que/utils/queue_management.rb
|
90
|
+
- lib/que/utils/ruby2_keywords.rb
|
87
91
|
- lib/que/utils/transactions.rb
|
88
92
|
- lib/que/version.rb
|
89
93
|
- lib/que/worker.rb
|
@@ -102,7 +106,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
102
106
|
requirements:
|
103
107
|
- - ">="
|
104
108
|
- !ruby/object:Gem::Version
|
105
|
-
version:
|
109
|
+
version: 2.7.0
|
106
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
111
|
requirements:
|
108
112
|
- - ">="
|