queue_classic 4.0.0.pre.beta1 → 4.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/codeql-analysis.yml +72 -0
- data/.github/workflows/main.yaml +71 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/README.md +38 -68
- data/lib/queue_classic/version.rb +1 -1
- data/lib/queue_classic/worker.rb +5 -1
- data/queue_classic.gemspec +2 -2
- data/test/rails-tests/rails523.sh +1 -1
- metadata +10 -9
- data/.circleci/config.yml +0 -192
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85cbe23c9e438cd6a641325666d15b2b9195e804807301551c2daf557edf5f1a
|
4
|
+
data.tar.gz: 5a83731ab2ee80532dc4e4e5af535e58301003a8064f92851793120520b88cff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9862ac7ed5c2d45d30524636cba00ac60b0939c240fc631a9e60561353ac115d49ce147d783cc454ddcb025676eaac7958368d286877e57d38bf1889924b3574
|
7
|
+
data.tar.gz: 83010a3b0450dd5128c72fdc41ac834baa7af97e3166a2a3e7bc8592213a7682f434b23c34c89635f2246112cbe240faa97d7bcb6bda4579703ed0d2e613cc71
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# For most projects, this workflow file will not need changing; you simply need
|
2
|
+
# to commit it to your repository.
|
3
|
+
#
|
4
|
+
# You may wish to alter this file to override the set of languages analyzed,
|
5
|
+
# or to provide custom queries or build logic.
|
6
|
+
#
|
7
|
+
# ******** NOTE ********
|
8
|
+
# We have attempted to detect the languages in your repository. Please check
|
9
|
+
# the `language` matrix defined below to confirm you have the correct set of
|
10
|
+
# supported CodeQL languages.
|
11
|
+
#
|
12
|
+
name: "CodeQL"
|
13
|
+
|
14
|
+
on:
|
15
|
+
push:
|
16
|
+
branches: [ master ]
|
17
|
+
pull_request:
|
18
|
+
# The branches below must be a subset of the branches above
|
19
|
+
branches: [ master ]
|
20
|
+
schedule:
|
21
|
+
- cron: '30 21 * * 0'
|
22
|
+
|
23
|
+
jobs:
|
24
|
+
analyze:
|
25
|
+
name: Analyze
|
26
|
+
runs-on: ubuntu-latest
|
27
|
+
permissions:
|
28
|
+
actions: read
|
29
|
+
contents: read
|
30
|
+
security-events: write
|
31
|
+
|
32
|
+
strategy:
|
33
|
+
fail-fast: false
|
34
|
+
matrix:
|
35
|
+
language: [ 'ruby' ]
|
36
|
+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
37
|
+
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
|
38
|
+
|
39
|
+
steps:
|
40
|
+
- name: Checkout repository
|
41
|
+
uses: actions/checkout@v3
|
42
|
+
|
43
|
+
# Initializes the CodeQL tools for scanning.
|
44
|
+
- name: Initialize CodeQL
|
45
|
+
uses: github/codeql-action/init@v2
|
46
|
+
with:
|
47
|
+
languages: ${{ matrix.language }}
|
48
|
+
# If you wish to specify custom queries, you can do so here or in a config file.
|
49
|
+
# By default, queries listed here will override any specified in a config file.
|
50
|
+
# Prefix the list here with "+" to use these queries and those in the config file.
|
51
|
+
|
52
|
+
# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
|
53
|
+
# queries: security-extended,security-and-quality
|
54
|
+
|
55
|
+
|
56
|
+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
57
|
+
# If this step fails, then you should remove it and run the build manually (see below)
|
58
|
+
- name: Autobuild
|
59
|
+
uses: github/codeql-action/autobuild@v2
|
60
|
+
|
61
|
+
# ℹ️ Command-line programs to run using the OS shell.
|
62
|
+
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
63
|
+
|
64
|
+
# If the Autobuild fails above, remove it and uncomment the following three lines.
|
65
|
+
# modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance.
|
66
|
+
|
67
|
+
# - run: |
|
68
|
+
# echo "Run, Build Application using script"
|
69
|
+
# ./location_of_script_within_repo/buildscript.sh
|
70
|
+
|
71
|
+
- name: Perform CodeQL Analysis
|
72
|
+
uses: github/codeql-action/analyze@v2
|
@@ -0,0 +1,71 @@
|
|
1
|
+
name: Test
|
2
|
+
on: push
|
3
|
+
jobs:
|
4
|
+
# test_rails:
|
5
|
+
# runs-on: ubuntu-latest
|
6
|
+
# services:
|
7
|
+
# postgres:
|
8
|
+
# image: postgres
|
9
|
+
# env:
|
10
|
+
# POSTGRES_PASSWORD: postgres
|
11
|
+
# options: >-
|
12
|
+
# --health-cmd pg_isready
|
13
|
+
# --health-interval 10s
|
14
|
+
# --health-timeout 5s
|
15
|
+
# --health-retries 5
|
16
|
+
# ports:
|
17
|
+
# - 5432:5432
|
18
|
+
# steps:
|
19
|
+
# - uses: actions/checkout@v3
|
20
|
+
# - name: Install postgresql-client
|
21
|
+
# run: |
|
22
|
+
# sudo apt-get update
|
23
|
+
# sudo apt-get install -y libpq-dev
|
24
|
+
# - uses: ruby/setup-ruby@v1
|
25
|
+
# with:
|
26
|
+
# ruby-version: "2.6"
|
27
|
+
# bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
28
|
+
# - name: Test clean install in Rails
|
29
|
+
# env:
|
30
|
+
# DATABASE_URL: postgres://postgres:postgres@localhost/qctest523
|
31
|
+
# run: |
|
32
|
+
# cd test/rails-tests/
|
33
|
+
# sh rails523.sh
|
34
|
+
test:
|
35
|
+
runs-on: ubuntu-latest
|
36
|
+
strategy:
|
37
|
+
fail-fast: false
|
38
|
+
matrix:
|
39
|
+
ruby_version: ['2.6', '2.7', '3.0', '3.1']
|
40
|
+
services:
|
41
|
+
postgres:
|
42
|
+
image: postgres
|
43
|
+
env:
|
44
|
+
POSTGRES_PASSWORD: postgres
|
45
|
+
options: >-
|
46
|
+
--health-cmd pg_isready
|
47
|
+
--health-interval 10s
|
48
|
+
--health-timeout 5s
|
49
|
+
--health-retries 5
|
50
|
+
ports:
|
51
|
+
- 5432:5432
|
52
|
+
steps:
|
53
|
+
- uses: actions/checkout@v3
|
54
|
+
- name: Install postgresql-client
|
55
|
+
run: |
|
56
|
+
sudo apt-get update
|
57
|
+
sudo apt-get install -y libpq-dev
|
58
|
+
- uses: ruby/setup-ruby@v1
|
59
|
+
with:
|
60
|
+
ruby-version: ${{ matrix.ruby_version }}
|
61
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
62
|
+
- name: Run tests
|
63
|
+
run: bundle exec rake
|
64
|
+
env:
|
65
|
+
RAILS_ENV: test
|
66
|
+
RACK_ENV: test
|
67
|
+
QC_DATABASE_URL: postgres://postgres:postgres@localhost/postgres
|
68
|
+
DATABASE_URL: postgres://postgres:postgres@localhost/postgres
|
69
|
+
QC_BENCHMARK: true
|
70
|
+
QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
|
71
|
+
QC_BENCHMARK_MAX_TIME_ENQUEUE: 10
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
|
5
|
+
## [4.0.0] - 2022-05-17
|
6
|
+
|
7
|
+
Updates:
|
8
|
+
- [Allow overriding of job successes](https://github.com/QueueClassic/queue_classic/pull/338)
|
9
|
+
- [Move to @github actions - @circleci ended up being slower. Test for Ruby 2.6, 2.7, 3.0 and 3.1. Require a more modern, but still old PG gem.](https://github.com/QueueClassic/queue_classic/pull/335)
|
10
|
+
- [Setup some code analysis](https://github.com/QueueClassic/queue_classic/pull/337)
|
11
|
+
|
5
12
|
## [4.0.0-alpha1] - 2019-07-18
|
6
13
|
|
7
14
|
Updates:
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -6,18 +6,17 @@ Why this over something like Resque. Two reasons:
|
|
6
6
|
1. Your jobs can be equeued in the same transaction as other modifications to the database, and will only be processed when everything is commited. This is a hard pattern to develop around for queues done outside your database
|
7
7
|
2. Less things to run, if you don't already have Redis or a dedicated queue in your stack.
|
8
8
|
|
9
|
-
|
9
|
+
![master](https://github.com/QueueClassic/queue_classic/actions/workflows/main.yaml/badge.svg?branch=master)
|
10
10
|
|
11
11
|
[![Gem Version](http://img.shields.io/gem/v/queue_classic.svg?style=flat)](http://badge.fury.io/rb/queue_classic)
|
12
12
|
|
13
|
-
**IMPORTANT NOTE: This README is representing the current work for queue_classic, which is generally the pending next version
|
13
|
+
**IMPORTANT NOTE: This README is representing the current work for queue_classic, which is generally the pending next version.**
|
14
14
|
|
15
15
|
You can always find the latest and previous releases here:
|
16
16
|
|
17
17
|
https://github.com/QueueClassic/queue_classic/releases
|
18
18
|
|
19
19
|
## Other related projects
|
20
|
-
|
21
20
|
If you're interested in this project, you might also want to checkout:
|
22
21
|
|
23
22
|
* [Que](https://github.com/que-rb/que)
|
@@ -27,35 +26,28 @@ If you're interested in this project, you might also want to checkout:
|
|
27
26
|
For a list of other queues (which may or may not be Postgres backed), checkout - https://edgeapi.rubyonrails.org/classes/ActiveJob/QueueAdapters.html
|
28
27
|
|
29
28
|
## What is queue_classic?
|
30
|
-
|
31
29
|
queue_classic provides a simple interface to a PostgreSQL-backed message queue. queue_classic specializes in concurrent locking and minimizing database load while providing a simple, intuitive developer experience. queue_classic assumes that you are already using PostgreSQL in your production environment and that adding another dependency (e.g. redis, beanstalkd, 0mq) is undesirable.
|
32
30
|
|
33
31
|
A major benefit is the ability to enqueue inside transactions, ensuring things are done only when your changes are commited.
|
34
32
|
|
35
33
|
## Other related projects
|
36
|
-
|
37
34
|
* [Queue Classic Plus](https://github.com/rainforestapp/queue_classic_plus) - adds support for retrying with specific exceptions, transaction processing of jobs, metric collection, etc
|
38
35
|
* [Queue Classic Admin](https://github.com/QueueClassic/queue_classic_admin) - Admin interface for queue_classic
|
39
36
|
* [Queue Classic Matchers](https://github.com/rainforestapp/queue_classic_matchers) - RSpec matchers for queue_classic
|
40
37
|
|
41
38
|
## Features
|
42
|
-
|
43
39
|
* Leverage of PostgreSQL's listen/notify, skip locked, and row locking.
|
44
40
|
* Support for multiple queues with heterogeneous workers.
|
45
41
|
* JSON data format.
|
46
42
|
* Workers can work multiple queues.
|
47
|
-
* ~~Forking workers.~~ (currently apparently broken https://github.com/QueueClassic/queue_classic/issues/207, a WIP fix exists but isn't merged tested yet https://github.com/QueueClassic/queue_classic/pull/216)
|
48
43
|
|
49
44
|
### Requirements
|
50
|
-
|
51
45
|
For this version, the requirements are as follows:
|
52
|
-
* Ruby 2.
|
46
|
+
* Ruby 2.6, 2.7, 3.0, 3.1 - i.e. currently supported Ruby versions
|
53
47
|
* Postgres ~> 9.6
|
54
|
-
* Rubygem: pg ~>
|
55
|
-
|
48
|
+
* Rubygem: pg ~> 1.1
|
56
49
|
|
57
50
|
## Table of contents
|
58
|
-
|
59
51
|
* [Documentation](https://www.rubydoc.info/gems/queue_classic/)
|
60
52
|
* [Usage](#usage)
|
61
53
|
* [Setup](#setup)
|
@@ -68,14 +60,13 @@ For this version, the requirements are as follows:
|
|
68
60
|
* [License](#license)
|
69
61
|
|
70
62
|
## Usage
|
71
|
-
|
72
63
|
There are 2 ways to use queue_classic:
|
73
64
|
|
74
65
|
* Producing Jobs
|
75
66
|
* Working Jobs
|
76
67
|
|
77
68
|
### Producing Jobs
|
78
|
-
|
69
|
+
#### Simple Enqueue
|
79
70
|
The first argument is a string which represents a ruby object and a method name. The second argument(s) will be passed along as arguments to the method defined by the first argument. The set of arguments will be encoded as JSON and stored in the database.
|
80
71
|
|
81
72
|
```ruby
|
@@ -99,6 +90,7 @@ p_queue = QC::Queue.new("priority_queue")
|
|
99
90
|
p_queue.enqueue("Kernel.puts", ["hello", "world"])
|
100
91
|
```
|
101
92
|
|
93
|
+
#### Scheduling for later
|
102
94
|
There is also the ability to schedule a job to run at a specified time in the future. The job will become processable after the specified time, and will be processed as-soon-as-possible.
|
103
95
|
|
104
96
|
```ruby
|
@@ -110,11 +102,9 @@ QC.enqueue_in(60, "Kernel.puts", "hello from 1 minute later")
|
|
110
102
|
```
|
111
103
|
|
112
104
|
### Working Jobs
|
113
|
-
|
114
|
-
There are two ways to work jobs. The first approach is to use the Rake task. The second approach is to use a custom executable.
|
105
|
+
There are two ways to work/process jobs. The first approach is to use the Rake task. The second approach is to use a custom executable.
|
115
106
|
|
116
107
|
#### Rake Task
|
117
|
-
|
118
108
|
Require queue_classic in your Rakefile:
|
119
109
|
|
120
110
|
```ruby
|
@@ -126,25 +116,24 @@ require 'queue_classic/tasks'
|
|
126
116
|
Start the worker via the Rakefile:
|
127
117
|
|
128
118
|
```bash
|
129
|
-
|
119
|
+
bundle exec rake qc:work
|
130
120
|
```
|
131
121
|
|
132
122
|
##### Work a single specific queue
|
133
123
|
Setup a worker to work only a specific, non-default queue:
|
134
124
|
|
135
125
|
```bash
|
136
|
-
|
126
|
+
QUEUE="priority_queue" bundle exec rake qc:work
|
137
127
|
```
|
138
128
|
|
139
129
|
##### Work multiple queues
|
140
130
|
In this scenario, on each iteration of the worker's loop, it will look for jobs in the first queue prior to looking at the second queue. This means that the first queue must be empty before the worker will look at the second queue.
|
141
131
|
|
142
132
|
```bash
|
143
|
-
|
133
|
+
QUEUES="priority_queue,secondary_queue" bundle exec rake qc:work
|
144
134
|
```
|
145
135
|
|
146
136
|
#### Custom Worker
|
147
|
-
|
148
137
|
This example is probably not production ready; however, it serves as an example of how to leverage the code in the Worker class to fit your non-default requirements.
|
149
138
|
|
150
139
|
```ruby
|
@@ -194,25 +183,22 @@ QC.default_worker_class = MyWorker
|
|
194
183
|
```
|
195
184
|
|
196
185
|
## Setup
|
197
|
-
|
198
186
|
In addition to installing the rubygem, you will need to prepare your database. Database preparation includes creating a table and loading PL/pgSQL functions. You can issue the database preparation commands using `psql` or use a database migration script.
|
199
187
|
|
200
188
|
### Quick Start
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
$ ruby -r queue_classic -e "QC::Worker.new.work"
|
189
|
+
```bash{:copy}
|
190
|
+
gem install queue_classic
|
191
|
+
createdb queue_classic_test
|
192
|
+
export QC_DATABASE_URL="postgres://username:password@localhost/queue_classic_test"
|
193
|
+
ruby -r queue_classic -e "QC::Setup.create"
|
194
|
+
ruby -r queue_classic -e "QC.enqueue('Kernel.puts', 'hello world')"
|
195
|
+
ruby -r queue_classic -e "QC::Worker.new.work"
|
209
196
|
```
|
210
197
|
|
211
198
|
### Ruby on Rails Setup
|
212
|
-
|
213
199
|
Declare dependencies in Gemfile:
|
214
200
|
|
215
|
-
```ruby
|
201
|
+
```ruby{:copy}
|
216
202
|
source 'https://rubygems.org' do
|
217
203
|
gem 'queue_classic'
|
218
204
|
end
|
@@ -226,82 +212,69 @@ bundle exec rake db:migrate
|
|
226
212
|
```
|
227
213
|
|
228
214
|
#### Database connection
|
215
|
+
Starting with with queue_classic 3.1, Rails is automatically detected and its connection is used. If you don't want to use the automatic database connection, set this environment variable to false: `export QC_RAILS_DATABASE=false`.
|
229
216
|
|
230
|
-
|
217
|
+
> **Note:** If you do not share the connection, you cannot enqueue in the same transaction as whatever you're doing in Rails.
|
231
218
|
|
232
219
|
**Note on using ActiveRecord migrations:** If you use the migration, and you wish to use commands that reset the database from the stored schema (e.g. `rake db:reset`), your application must be configured with `config.active_record.schema_format = :sql` in `config/application.rb`. If you don't do this, the PL/pgSQL function that queue_classic creates will be lost when you reset the database.
|
233
220
|
|
234
221
|
#### Active Job
|
235
|
-
|
236
222
|
If you use Rails 4.2+ and want to use Active Job, all you need to do is to set `config.active_job.queue_adapter = :queue_classic` in your `application.rb`. Everything else will be taken care for you. You can now use the Active Job functionality from now.
|
237
223
|
|
238
|
-
Just for your information, queue_classic detects your database connection and uses it.
|
239
|
-
|
240
|
-
|
241
224
|
### Plain Ruby Setup
|
225
|
+
If you're not using Rails, you can use the Rake task to prepare your database:
|
242
226
|
|
243
|
-
|
244
|
-
|
245
|
-
```bash
|
227
|
+
```bash{:copy}
|
246
228
|
# Creating the table and functions
|
247
|
-
|
229
|
+
bundle exec rake qc:create
|
248
230
|
|
249
231
|
# Dropping the table and functions
|
250
|
-
|
232
|
+
bundle exec rake qc:drop
|
251
233
|
```
|
252
234
|
|
253
235
|
#### Database connection
|
254
|
-
|
255
|
-
By default, queue_classic will use the QC_DATABASE_URL falling back on DATABASE_URL. The URL must be in the following format: `postgres://username:password@localhost/database_name`. If you use Heroku's PostgreSQL service, this will already be set. If you don't want to set this variable, you can set the connection in an initializer. **QueueClassic will maintain its own connection to the database.** This may double the number of connections to your database.
|
236
|
+
By default, queue_classic will use the `QC_DATABASE_URL` falling back on `DATABASE_URL`. The URL must be in the following format: `postgres://username:password@localhost/database_name`. If you use Heroku's PostgreSQL service, this will already be set. If you don't want to set this variable, you can set the connection in an initializer. **QueueClassic will maintain its own connection to the database.** This may double the number of connections to your database.
|
256
237
|
|
257
238
|
## Upgrading from earlier versions
|
258
|
-
|
259
239
|
If you are upgrading from a previous version of queue_classic, you might need some new database columns and/or functions. Luckily enough for you, it is easy to do so.
|
260
240
|
|
261
241
|
### Ruby on Rails
|
262
|
-
|
263
242
|
These two commands will add the newer migrations:
|
264
243
|
|
265
|
-
```bash
|
244
|
+
```bash{:copy}
|
266
245
|
rails generate queue_classic:install
|
267
246
|
bundle exec rake db:migrate
|
268
247
|
```
|
269
248
|
|
270
249
|
### Rake Task
|
271
|
-
|
272
250
|
This rake task will update you to the latest version:
|
273
|
-
|
251
|
+
|
252
|
+
```bash{:copy}
|
274
253
|
# Updating the table and functions
|
275
|
-
|
254
|
+
bundle exec rake qc:update
|
276
255
|
```
|
277
256
|
|
278
257
|
## Configuration
|
279
|
-
|
280
258
|
All configuration takes place in the form of environment vars. See [queue_classic.rb](https://github.com/QueueClassic/queue_classic/blob/master/lib/queue_classic.rb#L23-62) for a list of options.
|
281
259
|
|
282
260
|
## Logging
|
283
|
-
|
284
|
-
By default queue_classic does not talk very much.
|
285
|
-
If you find yourself in a situation where you need to know what's happening inside QC, there are two different kind of logging you can enable: DEBUG and MEASURE.
|
261
|
+
By default queue_classic does not talk very much. If you find yourself in a situation where you need to know what's happening inside QC, there are two different kind of logging you can enable: `DEBUG` and `MEASURE`.
|
286
262
|
|
287
263
|
### Measure
|
288
|
-
|
289
264
|
This will output the time to process and some more statistics. To enable it, set the `QC_MEASURE`:
|
290
265
|
|
291
|
-
```bash
|
266
|
+
```bash{:copy}
|
292
267
|
export QC_MEASURE="true"
|
293
268
|
```
|
294
269
|
|
295
270
|
### Debug
|
296
|
-
|
297
271
|
You can enable the debug output by setting the `DEBUG` environment variable:
|
298
272
|
|
299
|
-
```bash
|
273
|
+
```bash{:copy}
|
300
274
|
export DEBUG="true"
|
301
275
|
```
|
302
276
|
|
303
277
|
## Support
|
304
|
-
|
305
278
|
If you think you have found a bug, feel free to open an issue. Use the following template for the new issue:
|
306
279
|
|
307
280
|
1. List your versions: Ruby, PostgreSQL, queue_classic.
|
@@ -310,19 +283,16 @@ If you think you have found a bug, feel free to open an issue. Use the following
|
|
310
283
|
4. Provide sample codes & commands which will reproduce the problem.
|
311
284
|
|
312
285
|
## Hacking on queue_classic
|
313
|
-
|
314
286
|
### Running Tests
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
$ bundle exec ruby test/queue_test.rb # run a single test
|
287
|
+
```bash{:copy}
|
288
|
+
bundle
|
289
|
+
createdb queue_classic_test
|
290
|
+
export QC_DATABASE_URL="postgres://username:pass@localhost/queue_classic_test"
|
291
|
+
bundle exec rake # run all tests
|
292
|
+
bundle exec ruby test/queue_test.rb # run a single test
|
322
293
|
```
|
323
294
|
|
324
295
|
## License
|
325
|
-
|
326
296
|
Copyright (C) 2010 Ryan Smith
|
327
297
|
|
328
298
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
data/lib/queue_classic/worker.rb
CHANGED
@@ -111,7 +111,7 @@ module QC
|
|
111
111
|
finished = false
|
112
112
|
begin
|
113
113
|
call(job).tap do
|
114
|
-
queue
|
114
|
+
handle_success(queue, job)
|
115
115
|
finished = true
|
116
116
|
end
|
117
117
|
rescue StandardError, ScriptError, NoMemoryError => e
|
@@ -139,6 +139,10 @@ module QC
|
|
139
139
|
receiver.send(message, *args)
|
140
140
|
end
|
141
141
|
|
142
|
+
def handle_success(queue, job)
|
143
|
+
queue.delete(job[:id])
|
144
|
+
end
|
145
|
+
|
142
146
|
# This method will be called when a StandardError, ScriptError or
|
143
147
|
# NoMemoryError is raised during the execution of the job.
|
144
148
|
def handle_failure(job,e)
|
data/queue_classic.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.description = "queue_classic is a queueing library for Ruby apps. (Rails, Sinatra, Etc...) queue_classic features asynchronous job polling, database maintained locks and no ridiculous dependencies. As a matter of fact, queue_classic only requires pg."
|
11
11
|
spec.summary = "Simple, efficient worker queue for Ruby & PostgreSQL."
|
12
12
|
spec.authors = ["Ryan Smith (♠ ace hacker)"]
|
13
|
-
spec.homepage = "
|
13
|
+
spec.homepage = "https://github.com/QueueClassic/queue_classic"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
@@ -20,6 +20,6 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.require_paths = %w[lib]
|
22
22
|
|
23
|
-
spec.add_dependency "pg", ">=
|
23
|
+
spec.add_dependency "pg", ">= 1.1", "< 2.0"
|
24
24
|
spec.add_development_dependency "activerecord", ">= 5.0.0", "< 6.1"
|
25
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: queue_classic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Smith (♠ ace hacker)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pg
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '
|
29
|
+
version: '1.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2.0'
|
@@ -58,7 +58,8 @@ executables: []
|
|
58
58
|
extensions: []
|
59
59
|
extra_rdoc_files: []
|
60
60
|
files:
|
61
|
-
- ".
|
61
|
+
- ".github/workflows/codeql-analysis.yml"
|
62
|
+
- ".github/workflows/main.yaml"
|
62
63
|
- ".gitignore"
|
63
64
|
- CHANGELOG.md
|
64
65
|
- CODE_OF_CONDUCT.md
|
@@ -103,7 +104,7 @@ files:
|
|
103
104
|
- test/rails-tests/.gitignore
|
104
105
|
- test/rails-tests/rails523.sh
|
105
106
|
- test/worker_test.rb
|
106
|
-
homepage:
|
107
|
+
homepage: https://github.com/QueueClassic/queue_classic
|
107
108
|
licenses:
|
108
109
|
- MIT
|
109
110
|
metadata: {}
|
@@ -118,11 +119,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
119
|
version: '0'
|
119
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
121
|
requirements:
|
121
|
-
- - "
|
122
|
+
- - ">="
|
122
123
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
124
|
+
version: '0'
|
124
125
|
requirements: []
|
125
|
-
rubygems_version: 3.1.
|
126
|
+
rubygems_version: 3.1.6
|
126
127
|
signing_key:
|
127
128
|
specification_version: 4
|
128
129
|
summary: Simple, efficient worker queue for Ruby & PostgreSQL.
|
data/.circleci/config.yml
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
version: 2
|
2
|
-
jobs:
|
3
|
-
test_fresh_install_rails_5_2_3:
|
4
|
-
parallelism: 2
|
5
|
-
docker:
|
6
|
-
- image: circleci/ruby:2.6
|
7
|
-
environment:
|
8
|
-
RAILS_ENV: test
|
9
|
-
RACK_ENV: test
|
10
|
-
POSTGRES_USER: root
|
11
|
-
PGHOST: 127.0.0.1
|
12
|
-
DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
13
|
-
QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
14
|
-
QC_BENCHMARK: true
|
15
|
-
QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
|
16
|
-
- image: circleci/postgres:9.6.6-alpine
|
17
|
-
steps:
|
18
|
-
- checkout
|
19
|
-
- run:
|
20
|
-
name: Install rails, add QC and run migrations
|
21
|
-
command: |
|
22
|
-
cd test/rails-tests/
|
23
|
-
sh rails523.sh
|
24
|
-
test_ruby_2_4:
|
25
|
-
docker:
|
26
|
-
- image: circleci/ruby:2.4
|
27
|
-
environment:
|
28
|
-
RAILS_ENV: test
|
29
|
-
RACK_ENV: test
|
30
|
-
POSTGRES_USER: root
|
31
|
-
PGHOST: 127.0.0.1
|
32
|
-
DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
33
|
-
QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
34
|
-
QC_BENCHMARK: true
|
35
|
-
QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
|
36
|
-
- image: circleci/postgres:9.6.6-alpine
|
37
|
-
steps:
|
38
|
-
- checkout
|
39
|
-
- run:
|
40
|
-
name: Install env dependencies
|
41
|
-
command: |
|
42
|
-
sudo apt-get update
|
43
|
-
sudo apt-get install postgresql-client
|
44
|
-
- restore_cache:
|
45
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
46
|
-
}}
|
47
|
-
- run:
|
48
|
-
name: Install Ruby gems
|
49
|
-
command: |
|
50
|
-
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
|
51
|
-
- save_cache:
|
52
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
53
|
-
}}
|
54
|
-
paths:
|
55
|
-
- ~/project/vendor/bundle
|
56
|
-
- run:
|
57
|
-
name: Minitest
|
58
|
-
command: |
|
59
|
-
bundle exec rake
|
60
|
-
- store_artifacts:
|
61
|
-
path: test/reports/
|
62
|
-
- store_test_results:
|
63
|
-
path: test/reports/
|
64
|
-
test_ruby_2_5:
|
65
|
-
docker:
|
66
|
-
- image: circleci/ruby:2.5
|
67
|
-
environment:
|
68
|
-
RAILS_ENV: test
|
69
|
-
RACK_ENV: test
|
70
|
-
POSTGRES_USER: root
|
71
|
-
PGHOST: 127.0.0.1
|
72
|
-
DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
73
|
-
QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
74
|
-
QC_BENCHMARK: true
|
75
|
-
QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
|
76
|
-
- image: circleci/postgres:9.6.6-alpine
|
77
|
-
steps:
|
78
|
-
- checkout
|
79
|
-
- run:
|
80
|
-
name: Install env dependencies
|
81
|
-
command: |
|
82
|
-
sudo apt-get update
|
83
|
-
sudo apt-get install postgresql-client
|
84
|
-
- restore_cache:
|
85
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
86
|
-
}}
|
87
|
-
- run:
|
88
|
-
name: Install Ruby gems
|
89
|
-
command: |
|
90
|
-
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
|
91
|
-
- save_cache:
|
92
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
93
|
-
}}
|
94
|
-
paths:
|
95
|
-
- ~/project/vendor/bundle
|
96
|
-
- run:
|
97
|
-
name: Minitest
|
98
|
-
command: |
|
99
|
-
bundle exec rake
|
100
|
-
- store_artifacts:
|
101
|
-
path: test/reports/
|
102
|
-
- store_test_results:
|
103
|
-
path: test/reports/
|
104
|
-
test_ruby_2_6:
|
105
|
-
docker:
|
106
|
-
- image: circleci/ruby:2.6
|
107
|
-
environment:
|
108
|
-
RAILS_ENV: test
|
109
|
-
RACK_ENV: test
|
110
|
-
POSTGRES_USER: root
|
111
|
-
PGHOST: 127.0.0.1
|
112
|
-
DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
113
|
-
QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
114
|
-
QC_BENCHMARK: true
|
115
|
-
QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
|
116
|
-
- image: circleci/postgres:9.6.6-alpine
|
117
|
-
steps:
|
118
|
-
- checkout
|
119
|
-
- run:
|
120
|
-
name: Install env dependencies
|
121
|
-
command: |
|
122
|
-
sudo apt-get update
|
123
|
-
sudo apt-get install postgresql-client
|
124
|
-
- restore_cache:
|
125
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
126
|
-
}}
|
127
|
-
- run:
|
128
|
-
name: Install Ruby gems
|
129
|
-
command: |
|
130
|
-
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
|
131
|
-
- save_cache:
|
132
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
133
|
-
}}
|
134
|
-
paths:
|
135
|
-
- ~/project/vendor/bundle
|
136
|
-
- run:
|
137
|
-
name: Minitest
|
138
|
-
command: |
|
139
|
-
bundle exec rake
|
140
|
-
- store_artifacts:
|
141
|
-
path: test/reports/
|
142
|
-
- store_test_results:
|
143
|
-
path: test/reports/
|
144
|
-
test_ruby_2_7:
|
145
|
-
docker:
|
146
|
-
- image: circleci/ruby:2.7
|
147
|
-
environment:
|
148
|
-
RAILS_ENV: test
|
149
|
-
RACK_ENV: test
|
150
|
-
POSTGRES_USER: root
|
151
|
-
PGHOST: 127.0.0.1
|
152
|
-
DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
153
|
-
QC_DATABASE_URL: postgres://postgres@127.0.0.1/circle_test
|
154
|
-
QC_BENCHMARK: true
|
155
|
-
QC_BENCHMARK_MAX_TIME_DEQUEUE: 60
|
156
|
-
- image: circleci/postgres:9.6.6-alpine
|
157
|
-
steps:
|
158
|
-
- checkout
|
159
|
-
- run:
|
160
|
-
name: Install env dependencies
|
161
|
-
command: |
|
162
|
-
sudo apt-get update
|
163
|
-
sudo apt-get install postgresql-client
|
164
|
-
- restore_cache:
|
165
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
166
|
-
}}
|
167
|
-
- run:
|
168
|
-
name: Install Ruby gems
|
169
|
-
command: |
|
170
|
-
bundle check --path=vendor/bundle || bundle install --path=vendor/bundle --jobs=4 --retry=3
|
171
|
-
- save_cache:
|
172
|
-
key: v1-qc-bundler-{{ checksum "Gemfile" }}-{{ checksum "queue_classic.gemspec"
|
173
|
-
}}
|
174
|
-
paths:
|
175
|
-
- ~/project/vendor/bundle
|
176
|
-
- run:
|
177
|
-
name: Minitest
|
178
|
-
command: |
|
179
|
-
bundle exec rake
|
180
|
-
- store_artifacts:
|
181
|
-
path: test/reports/
|
182
|
-
- store_test_results:
|
183
|
-
path: test/reports/
|
184
|
-
workflows:
|
185
|
-
version: 2
|
186
|
-
test:
|
187
|
-
jobs:
|
188
|
-
- test_ruby_2_4
|
189
|
-
- test_ruby_2_5
|
190
|
-
- test_ruby_2_6
|
191
|
-
- test_ruby_2_7
|
192
|
-
- test_fresh_install_rails_5_2_3
|