famoseagle-carrot 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +1 -1
- data/lib/amqp/exchange.rb +5 -3
- data/lib/amqp/queue.rb +6 -4
- data/lib/carrot.rb +4 -4
- metadata +1 -1
data/VERSION.yml
CHANGED
data/lib/amqp/exchange.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
module Carrot::AMQP
|
2
2
|
class Exchange
|
3
|
-
|
3
|
+
attr_reader :server, :type, :name, :opts, :key, :carrot
|
4
4
|
|
5
|
-
def initialize(
|
6
|
-
@server, @type, @name, @opts = server, type, name, opts
|
5
|
+
def initialize(carrot, type, name, opts = {})
|
6
|
+
@server, @type, @name, @opts = carrot.server, type, name, opts
|
7
7
|
@key = opts[:key]
|
8
|
+
@carrot = carrot
|
8
9
|
|
9
10
|
unless name == "amq.#{type}" or name == ''
|
10
11
|
server.send_frame(
|
@@ -40,6 +41,7 @@ module Carrot::AMQP
|
|
40
41
|
server.send_frame(
|
41
42
|
Protocol::Exchange::Delete.new({ :exchange => name, :nowait => true }.merge(opts))
|
42
43
|
)
|
44
|
+
carrot.exchanges.delete(name)
|
43
45
|
end
|
44
46
|
|
45
47
|
def reset
|
data/lib/amqp/queue.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Carrot::AMQP
|
2
2
|
class Queue
|
3
|
-
attr_reader :name, :server
|
3
|
+
attr_reader :name, :server, :carrot
|
4
4
|
attr_accessor :delivery_tag
|
5
5
|
|
6
|
-
def initialize(
|
7
|
-
@server = server
|
6
|
+
def initialize(carrot, name, opts = {})
|
7
|
+
@server = carrot.server
|
8
8
|
@opts = opts
|
9
9
|
@name = name
|
10
|
+
@carrot = carrot
|
10
11
|
server.send_frame(
|
11
12
|
Protocol::Queue::Declare.new({ :queue => name, :nowait => true }.merge(opts))
|
12
13
|
)
|
@@ -78,11 +79,12 @@ module Carrot::AMQP
|
|
78
79
|
server.send_frame(
|
79
80
|
Protocol::Queue::Delete.new({ :queue => name, :nowait => true }.merge(opts))
|
80
81
|
)
|
82
|
+
carrot.queues.delete(name)
|
81
83
|
end
|
82
84
|
|
83
85
|
private
|
84
86
|
def exchange
|
85
|
-
@exchange ||= Exchange.new(
|
87
|
+
@exchange ||= Exchange.new(carrot, :direct, '', :key => name)
|
86
88
|
end
|
87
89
|
|
88
90
|
def bindings
|
data/lib/carrot.rb
CHANGED
@@ -34,7 +34,7 @@ class Carrot
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def queue(name, opts = {})
|
37
|
-
queues[name] ||= AMQP::Queue.new(
|
37
|
+
queues[name] ||= AMQP::Queue.new(self, name, opts)
|
38
38
|
end
|
39
39
|
|
40
40
|
def stop
|
@@ -46,15 +46,15 @@ class Carrot
|
|
46
46
|
end
|
47
47
|
|
48
48
|
def direct(name = 'amq.direct', opts = {})
|
49
|
-
exchanges[name] ||= Exchange.new(
|
49
|
+
exchanges[name] ||= AMQP::Exchange.new(self, :direct, name, opts)
|
50
50
|
end
|
51
51
|
|
52
52
|
def topic(name = 'amq.topic', opts = {})
|
53
|
-
exchanges[name] ||= Exchange.new(
|
53
|
+
exchanges[name] ||= AMQP::Exchange.new(self, :topic, name, opts)
|
54
54
|
end
|
55
55
|
|
56
56
|
def headers(name = 'amq.match', opts = {})
|
57
|
-
exchanges[name] ||= Exchange.new(
|
57
|
+
exchanges[name] ||= AMQP::Exchange.new(self, :headers, name, opts)
|
58
58
|
end
|
59
59
|
|
60
60
|
def exchanges
|