celerb 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/celerb.rb +1 -1
- data/lib/celerb/result_consumer.rb +0 -1
- data/lib/celerb/task.rb +4 -3
- data/lib/celerb/task_publisher.rb +11 -6
- metadata +4 -5
- data/.gemtest +0 -0
data/lib/celerb.rb
CHANGED
data/lib/celerb/task.rb
CHANGED
@@ -4,11 +4,12 @@ module Celerb
|
|
4
4
|
|
5
5
|
def self.included(base)
|
6
6
|
base.extend ClassMethods
|
7
|
+
base.send :attr_accessor, :queue
|
7
8
|
end
|
8
9
|
|
9
10
|
# Sends task to celery worker
|
10
11
|
def delay
|
11
|
-
self.class.delay self.to_celery
|
12
|
+
self.class.delay self.queue, self.to_celery
|
12
13
|
end
|
13
14
|
|
14
15
|
# Should return valid arguments for task specified by #task_name
|
@@ -22,14 +23,14 @@ module Celerb
|
|
22
23
|
@name = value
|
23
24
|
end
|
24
25
|
|
25
|
-
def delay(args)
|
26
|
+
def delay(queue, args)
|
26
27
|
argz = args.dup
|
27
28
|
kwargz = {}
|
28
29
|
if argz.last.kind_of? Hash
|
29
30
|
kwargz = argz.pop
|
30
31
|
end
|
31
32
|
AsyncResult.new(TaskPublisher.delay_task(
|
32
|
-
@name, task_args=argz, task_kwargs=kwargz))
|
33
|
+
queue, @name, task_args=argz, task_kwargs=kwargz))
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
@@ -2,17 +2,17 @@ module Celerb
|
|
2
2
|
class TaskPublisher
|
3
3
|
|
4
4
|
def self.connect(opts)
|
5
|
-
channel = AMQP::Channel.new
|
6
|
-
@
|
5
|
+
@channel = AMQP::Channel.new
|
6
|
+
@default_exchange = @channel.direct(opts[:exchange],
|
7
7
|
:key => opts[:key], :durable => true)
|
8
8
|
@results = ResultConsumer.new channel, opts
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.delay_task(task_name, task_args=[], task_kwargs={},
|
11
|
+
def self.delay_task(queue, task_name, task_args=[], task_kwargs={},
|
12
12
|
task_id=nil, taskset_id=nil, expires=nil, eta=nil,
|
13
13
|
exchange=nil, exchange_type=nil, retries=0)
|
14
14
|
task_id ||= TaskPublisher.uniq_id
|
15
|
-
publish({
|
15
|
+
publish(queue, {
|
16
16
|
:task => task_name,
|
17
17
|
:id => task_id,
|
18
18
|
:args => task_args,
|
@@ -30,8 +30,13 @@ module Celerb
|
|
30
30
|
|
31
31
|
private
|
32
32
|
|
33
|
-
def self.publish(body)
|
34
|
-
|
33
|
+
def self.publish(queue, body)
|
34
|
+
exchange = @default_exchange
|
35
|
+
if queue.kind_of? String
|
36
|
+
exchange = @channel.direct(queue, :key => queue,
|
37
|
+
:durable => true)
|
38
|
+
end
|
39
|
+
exchange.publish MessagePack.pack(body), {
|
35
40
|
:content_type => 'application/x-msgpack',
|
36
41
|
:content_encoding => 'binary'
|
37
42
|
}
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: celerb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 6
|
10
|
+
version: 0.3.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Dusan Maliarik
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-07-26 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -91,7 +91,6 @@ files:
|
|
91
91
|
- test/thumbTask.pb.rb
|
92
92
|
- test/thumbTask.proto
|
93
93
|
- test/vleugel.kmz
|
94
|
-
- .gemtest
|
95
94
|
has_rdoc: true
|
96
95
|
homepage: https://github.com/skrat/celerb
|
97
96
|
licenses: []
|
data/.gemtest
DELETED
File without changes
|