rabbit_jobs 0.0.8.3 → 0.0.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rabbit_jobs/job.rb +1 -0
- data/lib/rabbit_jobs/tasks.rb +0 -13
- data/lib/rabbit_jobs/version.rb +1 -1
- data/spec/fixtures/jobs.rb +13 -5
- data/spec/integration/publisher_spec.rb +5 -0
- metadata +8 -8
data/lib/rabbit_jobs/job.rb
CHANGED
@@ -23,6 +23,7 @@ module RabbitJobs::Job
|
|
23
23
|
Process.wait(@child_pid)
|
24
24
|
yield if block_given?
|
25
25
|
else
|
26
|
+
$0 = "##{@child_pid} #{self.class}.perform(#{ params.map(&:inspect).join(', ') }) #{$0}"
|
26
27
|
begin
|
27
28
|
if defined?(ActiveRecord::Base)
|
28
29
|
ActiveRecord::Base.establish_connection
|
data/lib/rabbit_jobs/tasks.rb
CHANGED
@@ -33,19 +33,6 @@ namespace :rj do
|
|
33
33
|
scheduler.work
|
34
34
|
end
|
35
35
|
|
36
|
-
desc "Start multiple Resque workers. Should only be used in dev mode."
|
37
|
-
task :workers do
|
38
|
-
threads = []
|
39
|
-
|
40
|
-
ENV['COUNT'].to_i.times do
|
41
|
-
threads << Thread.new do
|
42
|
-
system "rake resque:worker"
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
threads.each { |thread| thread.join }
|
47
|
-
end
|
48
|
-
|
49
36
|
# Preload app files if this is Rails
|
50
37
|
task :preload => :setup do
|
51
38
|
if defined?(Rails) && Rails.respond_to?(:application)
|
data/lib/rabbit_jobs/version.rb
CHANGED
data/spec/fixtures/jobs.rb
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
class TestJob
|
4
|
-
include
|
4
|
+
include RJ::Job
|
5
5
|
end
|
6
6
|
|
7
7
|
class PrintTimeJob
|
8
|
-
include
|
8
|
+
include RJ::Job
|
9
9
|
|
10
10
|
def self.perform(time)
|
11
11
|
puts "Running job queued at #{time}"
|
@@ -13,7 +13,7 @@ class PrintTimeJob
|
|
13
13
|
end
|
14
14
|
|
15
15
|
class JobWithExpire
|
16
|
-
include
|
16
|
+
include RJ::Job
|
17
17
|
expires_in 60*60 # expires in 1 hour
|
18
18
|
def self.perform
|
19
19
|
|
@@ -21,7 +21,7 @@ class JobWithExpire
|
|
21
21
|
end
|
22
22
|
|
23
23
|
class ExpiredJob
|
24
|
-
include
|
24
|
+
include RJ::Job
|
25
25
|
|
26
26
|
def self.perform
|
27
27
|
|
@@ -29,7 +29,7 @@ class ExpiredJob
|
|
29
29
|
end
|
30
30
|
|
31
31
|
class JobWithErrorHook
|
32
|
-
include
|
32
|
+
include RJ::Job
|
33
33
|
on_error :first_hook, lambda { puts "second hook" }, :last_hook
|
34
34
|
|
35
35
|
def first_hook(error)
|
@@ -43,4 +43,12 @@ class JobWithErrorHook
|
|
43
43
|
def self.perform
|
44
44
|
raise "Job raised an error at #{Time.now}"
|
45
45
|
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class JobWithArgsArray
|
49
|
+
include RJ::Job
|
50
|
+
|
51
|
+
def perform(first_param, *other_args)
|
52
|
+
puts "#{self.class.name}.perform called with first_param: #{first_param.inspect} and other_args: #{other_args.inspect}"
|
53
|
+
end
|
46
54
|
end
|
@@ -31,4 +31,9 @@ describe RabbitJobs::Publisher do
|
|
31
31
|
RabbitJobs.publish_to(:rspec_queue3, TestJob)
|
32
32
|
RabbitJobs::Publisher.purge_queue(:rspec_queue, :rspec_queue2, :rspec_queue3).should == 3
|
33
33
|
end
|
34
|
+
|
35
|
+
it 'should publish job with *params' do
|
36
|
+
RabbitJobs.publish_to(:rspec_queue, JobWithArgsArray, nil, 'first value', :some_symbol, 123, 'and string')
|
37
|
+
RabbitJobs::Publisher.purge_queue(:rspec_queue).should == 1
|
38
|
+
end
|
34
39
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbit_jobs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.8.
|
4
|
+
version: 0.0.8.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-02-
|
12
|
+
date: 2012-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|
16
|
-
requirement: &
|
16
|
+
requirement: &70113688710280 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0.9'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70113688710280
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70113690593620 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70113690593620
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rufus-scheduler
|
38
|
-
requirement: &
|
38
|
+
requirement: &70113690593080 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70113690593080
|
47
47
|
description: Background jobs on RabbitMQ
|
48
48
|
email:
|
49
49
|
- lazureykis@gmail.com
|