q4m 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +44 -2
- data/VERSION +1 -1
- data/lib/q4m.rb +2 -0
- metadata +4 -4
data/README.rdoc
CHANGED
@@ -1,9 +1,51 @@
|
|
1
1
|
= q4m
|
2
2
|
|
3
|
-
|
3
|
+
Interface to pragmatically setup a queue job for Q4M!
|
4
|
+
|
5
|
+
= Installation
|
6
|
+
|
7
|
+
kazu@utopia:~$ gem install q4m
|
8
|
+
|
9
|
+
= Usage
|
10
|
+
|
11
|
+
require 'rubygems'
|
12
|
+
require 'q4m'
|
13
|
+
|
14
|
+
class ShellJob < Q4m::Queue::Job
|
15
|
+
|
16
|
+
# *job* is a mysql record that is retrived from *table_name*
|
17
|
+
def execute job
|
18
|
+
# let the log know if the job was executed correctly!
|
19
|
+
job = job.first
|
20
|
+
return @log.info("Executed: #{job.inspect}") if system job
|
21
|
+
|
22
|
+
# If failed then log the job that failed and rollback the job so
|
23
|
+
# it stays in the queue!
|
24
|
+
@log.error "Aborted job: #{job.inspect}"
|
25
|
+
queue_abort
|
26
|
+
end
|
27
|
+
|
28
|
+
# Database q4m table (name) where jobs are stored
|
29
|
+
def table_name
|
30
|
+
'my_queue'
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
host = 'localhost'
|
36
|
+
user = 'root'
|
37
|
+
pass = 'secret'
|
38
|
+
database = 'my_db'
|
39
|
+
|
40
|
+
mysql = Mysql.new host, user, pass, database
|
41
|
+
job = ShellJob.new mysql, Logger.new('q4m.log')
|
42
|
+
|
43
|
+
job.run
|
44
|
+
|
45
|
+
|
4
46
|
|
5
47
|
== Note on Patches/Pull Requests
|
6
|
-
|
48
|
+
|
7
49
|
* Fork the project.
|
8
50
|
* Make your feature addition or bug fix.
|
9
51
|
* Add tests for it. This is important so I don't break it in a
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.2
|
data/lib/q4m.rb
CHANGED
@@ -27,6 +27,7 @@ module Q4m
|
|
27
27
|
def run
|
28
28
|
return unless @has_jobs
|
29
29
|
queue_wait
|
30
|
+
@log.info("Executing: #{latest_job.inspect}")
|
30
31
|
execute latest_job
|
31
32
|
queue_end
|
32
33
|
end
|
@@ -100,6 +101,7 @@ module Q4m
|
|
100
101
|
# start serving other workers
|
101
102
|
#
|
102
103
|
def queue_abort
|
104
|
+
@log.error 'Aborted!'
|
103
105
|
@mysql.query 'select queue_abort()'
|
104
106
|
end
|
105
107
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: q4m
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- kazuyoshi tlacaelel
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-08 00:00:00 -06:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|