queue_classic 2.0.3 → 2.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/queue_classic/conn.rb +10 -0
- data/readme.md +19 -6
- metadata +1 -1
data/lib/queue_classic/conn.rb
CHANGED
@@ -63,6 +63,16 @@ module QC
|
|
63
63
|
@connection ||= connect
|
64
64
|
end
|
65
65
|
|
66
|
+
def connection=(connection)
|
67
|
+
unless connection.instance_of? PG::Connection
|
68
|
+
raise(
|
69
|
+
ArgumentError,
|
70
|
+
"connection must be an instance of PG::Connection, but was #{connection.class}"
|
71
|
+
)
|
72
|
+
end
|
73
|
+
@connection = connection
|
74
|
+
end
|
75
|
+
|
66
76
|
def disconnect
|
67
77
|
connection.finish
|
68
78
|
ensure
|
data/readme.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# queue_classic
|
2
2
|
|
3
|
-
v2.0.
|
3
|
+
v2.0.4
|
4
4
|
|
5
5
|
queue_classic provides PostgreSQL-backed queueing focused on concurrent job
|
6
6
|
locking and minimizing database load while providing a simple, intuitive user
|
@@ -30,7 +30,7 @@ more advanced queueing features, you should investigate 0MQ, rabbitmq, or redis.
|
|
30
30
|
### Heroku Postgres
|
31
31
|
|
32
32
|
The Heroku Postgres team uses queue_classic to monitor the health of
|
33
|
-
customer databases,
|
33
|
+
customer databases, processing 200 jobs per second using a [fugu](https://postgres.heroku.com/pricing)
|
34
34
|
database. They chose queue_classic because of its simplicity and reliability.
|
35
35
|
|
36
36
|
### Cloudapp
|
@@ -82,15 +82,27 @@ require "queue_classic/tasks"
|
|
82
82
|
**config/initializers/queue_classic.rb**
|
83
83
|
|
84
84
|
```ruby
|
85
|
-
#
|
86
|
-
|
85
|
+
# queue_classic will by default look for an environment variable DATABASE_URL
|
86
|
+
# or QC_DATABASE_URL for a connection string in the format
|
87
|
+
# "postgres://username:password@localhost/database_name". If you use Heroku,
|
88
|
+
# this will already be set.
|
89
|
+
#
|
90
|
+
# If you don't want to set this variable, you can set the connection in an
|
91
|
+
# initializer.
|
92
|
+
QC::Conn.connection = ActiveRecord::Base.connection.raw_connection
|
87
93
|
```
|
88
94
|
|
89
95
|
queue_classic requires a database table and a PL/pgSQL function to be loaded
|
90
96
|
into your database. You can load the table and the function by running a migration
|
91
97
|
or using a rake task.
|
92
98
|
|
93
|
-
**db/
|
99
|
+
**db/migrations/add_queue_classic.rb**
|
100
|
+
|
101
|
+
If you use the migration, and you wish to use commands that reset the database
|
102
|
+
from the stored schema (e.g. `rake db:reset`), your application must be
|
103
|
+
configured with `config.active_record.schema_format = :sql` in
|
104
|
+
`config/application.rb`. If you don't do this, the PL/pgSQL function that
|
105
|
+
queue_classic creates will be lost when you reset the database.
|
94
106
|
|
95
107
|
```ruby
|
96
108
|
require 'queue_classic'
|
@@ -383,7 +395,7 @@ to do inside `handle_failure()`.
|
|
383
395
|
## Instrumentation
|
384
396
|
|
385
397
|
QC will log elapsed time, errors and general usage in the form of data.
|
386
|
-
To customize the output of the log data, override `QC.log` and `QC.log_yield`.
|
398
|
+
To customize the output of the log data, override `QC.log(data)` and `QC.log_yield(data)`.
|
387
399
|
By default, QC uses a simple wrapper around $stdout to put the log data in k=v
|
388
400
|
format. For instance:
|
389
401
|
|
@@ -556,6 +568,7 @@ end
|
|
556
568
|
* Ruby 1.9.2 (tests work in 1.8.7 but compatibility is not guaranteed or supported)
|
557
569
|
* Postgres ~> 9.0
|
558
570
|
* Rubygem: pg ~> 0.11.0
|
571
|
+
* For JRuby, see [queue_classic_java](https://github.com/bdon/queue_classic_java)
|
559
572
|
|
560
573
|
### Running Tests
|
561
574
|
|