queue_classic_pg2 3.2.0.RC1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/.travis.yml +19 -0
  4. data/CONTRIBUTING.md +17 -0
  5. data/Gemfile +9 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +326 -0
  8. data/Rakefile +14 -0
  9. data/changelog +146 -0
  10. data/lib/generators/queue_classic/install_generator.rb +36 -0
  11. data/lib/generators/queue_classic/templates/add_queue_classic.rb +9 -0
  12. data/lib/generators/queue_classic/templates/update_queue_classic_3_0_0.rb +9 -0
  13. data/lib/generators/queue_classic/templates/update_queue_classic_3_0_2.rb +11 -0
  14. data/lib/generators/queue_classic/templates/update_queue_classic_3_1_0.rb +9 -0
  15. data/lib/queue_classic/config.rb +85 -0
  16. data/lib/queue_classic/conn_adapter.rb +111 -0
  17. data/lib/queue_classic/queue.rb +119 -0
  18. data/lib/queue_classic/railtie.rb +9 -0
  19. data/lib/queue_classic/setup.rb +58 -0
  20. data/lib/queue_classic/tasks.rb +49 -0
  21. data/lib/queue_classic/version.rb +3 -0
  22. data/lib/queue_classic/worker.rb +166 -0
  23. data/lib/queue_classic.rb +122 -0
  24. data/queue_classic.gemspec +24 -0
  25. data/sql/create_table.sql +25 -0
  26. data/sql/ddl.sql +78 -0
  27. data/sql/downgrade_from_3_0_0.sql +2 -0
  28. data/sql/downgrade_from_3_1_0.sql +1 -0
  29. data/sql/drop_ddl.sql +3 -0
  30. data/sql/update_to_3_0_0.sql +17 -0
  31. data/sql/update_to_3_1_0.sql +9 -0
  32. data/test/benchmark_test.rb +39 -0
  33. data/test/config_test.rb +121 -0
  34. data/test/helper.rb +61 -0
  35. data/test/helper.sql +25 -0
  36. data/test/lib/queue_classic_rails_connection_test.rb +43 -0
  37. data/test/lib/queue_classic_test.rb +42 -0
  38. data/test/queue_test.rb +208 -0
  39. data/test/worker_test.rb +219 -0
  40. metadata +112 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: afdc18c05f5f58df0d6faf6b8e0a993d89672ea71605d81bb472b11e24aabbaa
4
+ data.tar.gz: e8be23038d61da8be0e3f10f16b59b3eb9edc927da5e5eb71f6fd168fb9ca636
5
+ SHA512:
6
+ metadata.gz: d2a6459471f79073ffc56cbf18c286538365d2c203adb3b7ad9352b298be236f47022e06422412d98c965edc14e7c214e3198effd3ca6a8597f7cc587b79d73c
7
+ data.tar.gz: ac85327e74443bdc04c8c9a579b412bbba0133dd5424294b0b7af144226f58ed97f5fbd46dbd76c79ab3464b68a0ad9056d7e73c11afd218910934d4b95bcb49
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ .db
2
+ .ruby-version
3
+ .bundle
4
+ .rvmrc
5
+ etc/
6
+ *.gem
7
+ .env
8
+ Gemfile.lock
9
+ tips-and-tricks.md
data/.travis.yml ADDED
@@ -0,0 +1,19 @@
1
+ language: ruby
2
+ before_install:
3
+ - gem update bundler --no-document
4
+ before_script:
5
+ - psql -c 'create database queue_classic_test;' -U postgres
6
+ env:
7
+ global:
8
+ - QC_DATABASE_URL="postgres://postgres@localhost/queue_classic_test"
9
+ - QC_BENCHMARK=true
10
+ - QC_BENCHMARK_MAX_TIME_DEQUEUE=60
11
+ rvm:
12
+ - 2.4.1
13
+ - 2.3.4
14
+ - 2.2.7
15
+ - 2.1.10
16
+ - 2.0.0
17
+ - 1.9.3
18
+ addons:
19
+ postgresql: 9.3
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,17 @@
1
+ queue_classic is a volunteer effort. We encourage you to pitch in.
2
+
3
+ 1. Fork queue_classic
4
+ 2. Create a topic branch - `git checkout -b my_branch`
5
+ 3. Push to your branch - `git push origin my_branch`
6
+ 4. Send us a pull-request for your topic branch
7
+ 5. That's it!
8
+
9
+ If you make code changes, please check that your patch:
10
+
11
+ 1. has tests
12
+ 2. works on Rails and non-Rails projects
13
+ 3. updates documentation
14
+
15
+ Thanks! :heart:
16
+
17
+ queue_classic Team
data/Gemfile ADDED
@@ -0,0 +1,9 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem "rake"
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem 'minitest', '~> 5.5.1'
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ MIT License
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,326 @@
1
+ # queue_classic
2
+
3
+ <p align="center">
4
+ <b>Simple, efficient worker queue for Ruby & PostgreSQL</b>
5
+ <br />
6
+ <a href="https://travis-ci.org/QueueClassic/queue_classic"><img src="http://img.shields.io/travis/QueueClassic/queue_classic/master.svg?style=flat" /></a>
7
+
8
+ <a href="https://codeclimate.com/github/QueueClassic/queue_classic"><img src="http://img.shields.io/codeclimate/github/QueueClassic/queue_classic.svg?style=flat" /></a>
9
+
10
+ <a href="http://badge.fury.io/rb/queue_classic"><img src="http://img.shields.io/gem/v/queue_classic.svg?style=flat" alt="Gem Version" height="18"></a>
11
+ </p>
12
+
13
+
14
+ **IMPORTANT NOTE REGARDING VERSIONS**
15
+
16
+ **This README is representing the current work for queue_classic edge [unstable]. You can find the README for other versions:**
17
+
18
+ - current release candidate: [v3.2.0.RC1](https://github.com/QueueClassic/queue_classic/tree/v3.2.0.RC1)
19
+ - latest stable can be found: [v3.1.x](https://github.com/QueueClassic/queue_classic/tree/3-1-stable)
20
+ - older stable: [v3.0.x](https://github.com/QueueClassic/queue_classic/tree/3-0-stable)
21
+
22
+
23
+ ## What is queue_classic?
24
+
25
+ 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.
26
+
27
+ ## Features
28
+
29
+ * Leverage of PostgreSQL's listen/notify & row locking.
30
+ * Support for multiple queues with heterogeneous workers.
31
+ * JSON data format.
32
+ * Forking workers.
33
+ * Workers can work multiple queues.
34
+ * Reduced row contention using a [relaxed FIFO](http://www.cs.tau.ac.il/~shanir/nir-pubs-web/Papers/Lock_Free.pdf) technique.
35
+
36
+ ## Table of content
37
+
38
+ * [Documentation](http://rubydoc.info/gems/queue_classic/2.2.3/frames)
39
+ * [Usage](#usage)
40
+ * [Setup](#setup)
41
+ * [Upgrade from earlier versions to V3.1](#upgrade-from-earlier-versions)
42
+ * [Configuration](#configuration)
43
+ * [JSON](#json)
44
+ * [Logging](#logging)
45
+ * [Support](#support)
46
+ * [Hacking](#hacking-on-queue_classic)
47
+ * [License](#license)
48
+
49
+ ## Usage
50
+
51
+ There are 2 ways to use queue_classic.
52
+
53
+ * Producing Jobs
54
+ * Working Jobs
55
+
56
+ ### Producing Jobs
57
+
58
+ 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 invocation defined by the first argument. The set of arguments will be encoded as JSON in the database.
59
+
60
+ ```ruby
61
+ # This method has no arguments.
62
+ QC.enqueue("Time.now")
63
+
64
+ # This method has 1 argument.
65
+ QC.enqueue("Kernel.puts", "hello world")
66
+
67
+ # This method has 2 arguments.
68
+ QC.enqueue("Kernel.printf", "hello %s", "world")
69
+
70
+ # This method has a hash argument.
71
+ QC.enqueue("Kernel.puts", {"hello" => "world"})
72
+
73
+ # This method has an array argument.
74
+ QC.enqueue("Kernel.puts", ["hello", "world"])
75
+
76
+ # This method uses a non-default queue.
77
+ p_queue = QC::Queue.new("priority_queue")
78
+ p_queue.enqueue("Kernel.puts", ["hello", "world"])
79
+ ```
80
+
81
+ There is also the possibility to schedule a job at a specified time in the future. It will not be worked off before that specified time.
82
+
83
+ ```ruby
84
+ # Specifying the job execution time exactly.
85
+ QC.enqueue_at(Time.new(2024,01,02,10,00), "Kernel.puts", "hello future")
86
+
87
+ # Specifying the job execution time as an offset in seconds.
88
+ QC.enqueue_in(60, "Kernel.puts", "hello from 1 minute later")
89
+ ```
90
+
91
+ ### Working Jobs
92
+
93
+ 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.
94
+
95
+ #### Rake Task
96
+
97
+ Require queue_classic in your Rakefile.
98
+
99
+ ```ruby
100
+ require 'queue_classic'
101
+ require 'queue_classic/tasks'
102
+ ```
103
+
104
+ Start the worker via the Rakefile.
105
+ ```bash
106
+ $ bundle exec rake qc:work
107
+ ```
108
+
109
+ Setup a worker to work a non-default queue.
110
+ ```bash
111
+ $ QUEUE="priority_queue" bundle exec rake qc:work
112
+ ```
113
+
114
+ Setup a worker to work multiple queues.
115
+ ```bash
116
+ $ QUEUES="priority_queue,secondary_queue" bundle exec rake qc:work
117
+ ```
118
+ 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.
119
+
120
+ #### Custom Worker
121
+
122
+ 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.
123
+
124
+ ```ruby
125
+ require 'timeout'
126
+ require 'queue_classic'
127
+
128
+ FailedQueue = QC::Queue.new("failed_jobs")
129
+
130
+ class MyWorker < QC::Worker
131
+
132
+ # A job is a Hash containing these attributes:
133
+ # :id Integer, the job id
134
+ # :method String, containing the object and method
135
+ # :args String, the arguments
136
+ # :q_name String, the queue name
137
+ # :scheduled_at Time, the scheduled time if the job was scheduled
138
+
139
+ # Execute the job using the methods and arguments
140
+ def call(job)
141
+ # Do something with the job
142
+ ...
143
+ end
144
+
145
+ # This method will be called when an exception
146
+ # is raised during the execution of the job.
147
+ # First argument is the job that failed.
148
+ # Second argument is the exception.
149
+ def handle_failure(job, e)
150
+ FailedQueue.enqueue(job[:method], *job[:args])
151
+ end
152
+
153
+ end
154
+
155
+ worker = MyWorker.new
156
+
157
+ trap('INT') { exit }
158
+ trap('TERM') { worker.stop }
159
+
160
+ loop do
161
+ queue, job = worker.lock_job
162
+ Timeout::timeout(5) { worker.process(queue, job) }
163
+ end
164
+ ```
165
+
166
+ The `qc:work` rake task uses `QC::Worker` by default. However, it's easy to
167
+ inject your own worker class:
168
+
169
+ ```ruby
170
+ QC.default_worker_class = MyWorker
171
+ ```
172
+
173
+ ## Setup
174
+
175
+ 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(1)` or use a database migration script.
176
+
177
+ ### Quick Start
178
+
179
+ ```bash
180
+ $ gem install queue_classic
181
+ $ createdb queue_classic_test
182
+ $ export QC_DATABASE_URL="postgres://username:password@localhost/queue_classic_test"
183
+ $ ruby -r queue_classic -e "QC::Setup.create"
184
+ $ ruby -r queue_classic -e "QC.enqueue('Kernel.puts', 'hello world')"
185
+ $ ruby -r queue_classic -e "QC::Worker.new.work"
186
+ ```
187
+
188
+ ### Ruby on Rails Setup
189
+
190
+ Declare dependencies in Gemfile.
191
+ ```ruby
192
+ source "https://rubygems.org"
193
+ gem "queue_classic"
194
+ ```
195
+
196
+ Add the database tables and stored procedures.
197
+
198
+ ```
199
+ rails generate queue_classic:install
200
+ bundle exec rake db:migrate
201
+ ```
202
+
203
+ #### Active Job
204
+
205
+ If you use Rails 4.2+, 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.
206
+
207
+ Just for your information, queue_classic detects your database connection and uses it.
208
+
209
+ ### Rake Task Setup
210
+
211
+ Alternatively, you can use the Rake task to prepare your database.
212
+
213
+ ```bash
214
+ # Creating the table and functions
215
+ $ bundle exec rake qc:create
216
+
217
+ # Dropping the table and functions
218
+ $ bundle exec rake qc:drop
219
+ ```
220
+
221
+ ### Database connection
222
+
223
+ #### Ruby on Rails
224
+
225
+ Starting with with queue_classic 3.1, Rails is automatically detected and its connection is used.
226
+
227
+ If you don't want to use the automatic database connection, set this environment variable to false: `export QC_RAILS_DATABASE=false`
228
+
229
+ **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.
230
+
231
+
232
+ #### Other Ruby apps
233
+
234
+ 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.
235
+
236
+ ## Upgrade from earlier versions
237
+ 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.
238
+
239
+ ### Ruby on Rails
240
+
241
+ You just need to run those lines, which will copy the new required migrations:
242
+
243
+ ```
244
+ rails generate queue_classic:install
245
+ bundle exec rake db:migrate
246
+ ```
247
+ ### Rake Task
248
+
249
+ This rake task will get you covered:
250
+ ```bash
251
+ # Updating the table and functions
252
+ $ bundle exec rake qc:update
253
+ ```
254
+
255
+ ## Configuration
256
+
257
+ 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.
258
+
259
+ ## JSON
260
+
261
+ If you are running PostgreSQL 9.4 or higher, queue_classic will use the [jsonb](http://www.postgresql.org/docs/9.4/static/datatype-json.html) datatype for new tables. Versions 9.2 and 9.3 will use the `json` data type and versions 9.1 and lower will use the `text` data type.
262
+ If you are updating queue_classic and are running PostgreSQL >= 9.4, run the following to switch to `jsonb`:
263
+ ```
264
+ alter table queue_classic_jobs alter column args type jsonb using (args::jsonb);
265
+ ```
266
+
267
+ ## Logging
268
+
269
+ By default queue_classic does not talk very much.
270
+ 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.
271
+
272
+ ### Measure
273
+ This will output the time to process and that kind of thing. To enable it, set the `QC_MEASURE`:
274
+
275
+ ```
276
+ export QC_MEASURE="true"
277
+ ```
278
+
279
+ ### Debug
280
+ You can enable the debug output by setting the `DEBUG` environment variable:
281
+
282
+ ```
283
+ export DEBUG="true"
284
+ ```
285
+
286
+ ## Support
287
+
288
+ If you think you have found a bug, feel free to open an issue. Use the following template for the new issue:
289
+
290
+ 1. List Versions: Ruby, PostgreSQL, queue_classic.
291
+ 2. Define what you would have expected to happen.
292
+ 3. List what actually happened.
293
+ 4. Provide sample codes & commands which will reproduce the problem.
294
+
295
+ If you have general questions about how to use queue_classic, send a message to the mailing list:
296
+
297
+ https://groups.google.com/d/forum/queue_classic
298
+
299
+ ## Hacking on queue_classic
300
+
301
+ ### Dependencies
302
+
303
+ * Ruby 1.9.2
304
+ * Postgres ~> 9.0
305
+ * Rubygem: pg ~> 0.11.0
306
+ * For JRuby, see [queue_classic_java](https://github.com/bdon/queue_classic_java)
307
+
308
+ ### Running Tests
309
+
310
+ ```bash
311
+ $ bundle
312
+ $ createdb queue_classic_test
313
+ $ export QC_DATABASE_URL="postgres://username:pass@localhost/queue_classic_test"
314
+ $ bundle exec rake # run all tests
315
+ $ bundle exec ruby test/queue_test.rb # run a single test
316
+ ```
317
+
318
+ ## License
319
+
320
+ Copyright (C) 2010 Ryan Smith
321
+
322
+ 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:
323
+
324
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
325
+
326
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ $:.unshift("lib")
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+ require "./lib/queue_classic"
6
+ require "./lib/queue_classic/tasks"
7
+
8
+ task :default => ['test']
9
+ Rake::TestTask.new do |t|
10
+ t.libs << 'test'
11
+ t.test_files = FileList['test/**/*_test.rb']
12
+ t.verbose = true
13
+ t.warning = true
14
+ end
data/changelog ADDED
@@ -0,0 +1,146 @@
1
+ Unreleased
2
+ - Fixed a bug in the offset calculation of `.enqueue_at`.
3
+ - Use the jsonb type for the args column from now on. If not available, fall back to json or text.
4
+ - `enqueue`, `enqueue_at`, `enqueue_in` return job hash with id.
5
+ - Fixed unlock query for versions below Postgres 9.2
6
+
7
+ Version 3.0.0rc
8
+ - Improved signal handling
9
+
10
+ Version 3.0.0beta
11
+ - Workers can process many queues.
12
+
13
+ Version 2.2.3
14
+ - Update pg dependency to 0.17.0
15
+
16
+ Version 2.3.0beta [YANKED]
17
+ - Concurrent job processing.
18
+
19
+ Version 2.2.2
20
+ - Update pg dependency to 0.16.0
21
+
22
+ Version 2.2.1
23
+ - Force listen/notify on worker
24
+ - Notifications happen inside PostgreSQL trigger
25
+ - Add rake task for generating rails migrations
26
+ - Fix bug related to listening worker
27
+
28
+ Version 2.2.0
29
+ - Use json from the stdlib in place of MultiJson.
30
+ - Use postgresql's json type for the args column if json type is available
31
+ - QC::Worker#handle_failure logs the job and the error
32
+ - QC.default_queue= to set your own default queue. (can be used
33
+ in testing to configure a mock queue)
34
+ - QC.log now reports time elapsed in milliseconds.
35
+
36
+ Version 2.1.4
37
+ - Update pg dependency to 0.15.1
38
+ - Document logging behaviour
39
+
40
+ Version 2.1.3
41
+ - Use MultiJson (Ezekiel Templin: #106)
42
+
43
+ Version 2.1.2
44
+ - Use 64bit ints as default data types in PostgreSQL
45
+ - Add process method in worker
46
+ - Allow percent-encoded socket paths in DATABASE_URL
47
+
48
+ Version 2.1.1
49
+ - Update pg gem version
50
+
51
+ Version 2.1.0
52
+ - Wrap connection execution in mutex making it thread safe
53
+ - Cleanup logging
54
+ - Refactor worker class making it more extensible
55
+ - Added rdoc style docs for worker class
56
+
57
+ Version 2.0.5
58
+ - Allow term signal to halt the lock_job function
59
+
60
+ Version 2.0.4
61
+ - Provider a connection setter.
62
+
63
+ Version 2.0.3
64
+ - Fix typo :(
65
+
66
+ Version 2.0.2
67
+ - Remove scrolls dependency
68
+ - Fix issue with notify not working on non-default queues
69
+
70
+ Version 2.0.1
71
+
72
+ Version 2.0.0
73
+ - Simpler setup via QC::Setup.create (rake qc:create) & QC::Setup.drop (rake
74
+ qc:drop)
75
+ - Simpler abstractions in implementation
76
+ - Better support for instrumentation via log_yield hook in QC module
77
+ - Multiple queues use one table with a queue_name column
78
+
79
+ Version 1.0.2
80
+ - Update to latest okjson as the current has bugs
81
+
82
+ Version 1.0.1
83
+ - Using OkJson instead of any sort of rubygem
84
+ - Remove html from docs
85
+ - Use parameterised queries
86
+ - Don't set application name by default
87
+ - Injection attack bug fixed in lock_head()
88
+ - Notificaiton get sent on seperate chans for disjoint queues
89
+
90
+ Version 1.0.0rc1
91
+ - Removed json gem and relying on ruby 1.9.2's stdlib
92
+ - Added better documentation
93
+
94
+ Version 0.3.6pre
95
+ - Added listen/notify support configured by $QC_LISTENING_WORKER otherwise uses Kernel.sleep()
96
+
97
+ Version 0.3.5pre
98
+ - Removed debug statement. Mistake!
99
+
100
+ Version 0.3.4pre
101
+ - Added logging configured by $VERBOSE or $QC_VERBOSE.
102
+ - Added a method setup_child that gets called right after a worker forks.
103
+ - Removed database helper methods: create_table, drop_table, silence_warnings.
104
+ - Removed queue connection helper methods. Status should be discoverd by psql or the likes.
105
+
106
+ Version 0.3.3pre
107
+ - Removed PUB/SUB
108
+ - Added GC after working a job
109
+ - Added support for a database_url other than $DATABASE_URL. $QC_DATABASE_URL
110
+ - Added exp backoff configured by $QC_MAX_LOCK_ATTEMPTS (default = 5)
111
+ - Added option for forking worker configured by $QC_FORK_WORKER (default = false)
112
+
113
+ Version 0.3.2
114
+ - Fixed bug which caused workers to consume 2 connections. Now they only consume 1
115
+ - Added a rake file for tests
116
+ - Added support for postgres:///db_name DATABASE_URLs
117
+
118
+ Version 0.3.1
119
+ - Added query interface for introspection success
120
+ - Moved the locking of jobs into the DB as a PG function. SELECT lock_head()
121
+ - Added requirement for DB connection. MUST BE URI i.e. DATABASE_URL=postgres://user:pass@localhost/db_name
122
+ - Added rake qc:create_queue. This task will add a new table. Use this for multiple queues.
123
+ - Added a bit of randomness to the lock_head() function. Helps you scale to a hilarious number of workers.
124
+ - Added support for trapping INT and TERM signals in the worker. ^C to stop after finished and ^C^C to kill.
125
+ - Renamed the jobs table to queue_classic_jobs
126
+ - Renamed the jobs channel to queue_classic_jobs
127
+ - Added support for multiple queues
128
+
129
+ Version 0.2.2
130
+ - Fixed problems with enqueueing a list of parameters.
131
+
132
+ Version 0.2.1
133
+ - Added method for handling errors.
134
+ - Added ability to enqueue a Job instance. Makes retrying jobs easier.
135
+ - Added delete_all.
136
+ - Fixed connection algorithm. 1 connection per process.
137
+ - Fixed API for enqueue. Now accepting 1 arg or many args.
138
+
139
+ Version 0.2.0
140
+ - Beta Release
141
+ - Added method for handling failed jobs
142
+ - Added Benchmarks
143
+ - Removed logging
144
+ - Moved the Job class into it's own file
145
+
146
+ 0.1.6
@@ -0,0 +1,36 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'active_record'
4
+
5
+ module QC
6
+ class InstallGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+
9
+ namespace "queue_classic:install"
10
+ self.source_paths << File.join(File.dirname(__FILE__), 'templates')
11
+ desc 'Generates (but does not run) a migration to add a queue_classic table.'
12
+
13
+ def self.next_migration_number(dirname)
14
+ next_migration_number = current_migration_number(dirname) + 1
15
+ ActiveRecord::Migration.next_migration_number(next_migration_number)
16
+ end
17
+
18
+ def create_migration_file
19
+ if self.class.migration_exists?('db/migrate', 'add_queue_classic').nil?
20
+ migration_template 'add_queue_classic.rb', 'db/migrate/add_queue_classic.rb'
21
+ end
22
+
23
+ if self.class.migration_exists?('db/migrate', 'update_queue_classic_3_0_0').nil?
24
+ migration_template 'update_queue_classic_3_0_0.rb', 'db/migrate/update_queue_classic_3_0_0.rb'
25
+ end
26
+
27
+ if self.class.migration_exists?('db/migrate', 'update_queue_classic_3_0_2').nil?
28
+ migration_template 'update_queue_classic_3_0_2.rb', 'db/migrate/update_queue_classic_3_0_2.rb'
29
+ end
30
+
31
+ if self.class.migration_exists?('db/migrate', 'update_queue_classic_3_1_0').nil?
32
+ migration_template 'update_queue_classic_3_1_0.rb', 'db/migrate/update_queue_classic_3_1_0.rb'
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,9 @@
1
+ class AddQueueClassic < ActiveRecord::Migration
2
+ def self.up
3
+ QC::Setup.create
4
+ end
5
+
6
+ def self.down
7
+ QC::Setup.drop
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ class UpdateQueueClassic300 < ActiveRecord::Migration
2
+ def self.up
3
+ QC::Setup.update_to_3_0_0
4
+ end
5
+
6
+ def self.down
7
+ QC::Setup.downgrade_from_3_0_0
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ class UpdateQueueClassic302 < ActiveRecord::Migration
2
+ def self.up
3
+ QC::Setup.update_to_3_0_0
4
+ end
5
+
6
+ def self.down
7
+ # This migration is fixing a bug, so we don't want to do anything here.
8
+ # I didn't want to make it irreversible either, as it could prevent
9
+ # rolling back other, unrelated, stuff.
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ class UpdateQueueClassic310 < ActiveRecord::Migration
2
+ def self.up
3
+ QC::Setup.update_to_3_1_0
4
+ end
5
+
6
+ def self.down
7
+ QC::Setup.downgrade_from_3_1_0
8
+ end
9
+ end