famoseagle-sweat_shop 0.5.0 → 0.6.0
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/VERSION.yml +1 -1
- data/lib/message_queue/rabbit.rb +33 -7
- metadata +2 -2
data/VERSION.yml
CHANGED
data/lib/message_queue/rabbit.rb
CHANGED
|
@@ -10,25 +10,51 @@ module MessageQueue
|
|
|
10
10
|
end
|
|
11
11
|
|
|
12
12
|
def delete(queue)
|
|
13
|
-
|
|
13
|
+
send_command do
|
|
14
|
+
client.queue(queue).delete
|
|
15
|
+
end
|
|
14
16
|
end
|
|
15
17
|
|
|
16
18
|
def queue_size(queue)
|
|
17
|
-
|
|
19
|
+
send_command do
|
|
20
|
+
client.queue(queue).message_count
|
|
21
|
+
end
|
|
18
22
|
end
|
|
19
23
|
|
|
20
24
|
def enqueue(queue, data)
|
|
21
|
-
|
|
25
|
+
send_command do
|
|
26
|
+
client.queue(queue, :durable => true).publish(Marshal.dump(data), :persistent => true)
|
|
27
|
+
end
|
|
22
28
|
end
|
|
23
29
|
|
|
24
30
|
def dequeue(queue)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
send_command do
|
|
32
|
+
task = client.queue(queue).pop(:ack => true)
|
|
33
|
+
return unless task
|
|
34
|
+
Marshal.load(task)
|
|
35
|
+
end
|
|
28
36
|
end
|
|
29
37
|
|
|
30
38
|
def confirm(queue)
|
|
31
|
-
|
|
39
|
+
send_command do
|
|
40
|
+
client.queue(queue).ack
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def send_command(&block)
|
|
45
|
+
retried = false
|
|
46
|
+
begin
|
|
47
|
+
block.call
|
|
48
|
+
rescue Carrot::AMQP::Server::ServerDown => e
|
|
49
|
+
if not retried
|
|
50
|
+
puts "Error #{e.message}. Retrying..."
|
|
51
|
+
@client = nil
|
|
52
|
+
retried = true
|
|
53
|
+
retry
|
|
54
|
+
else
|
|
55
|
+
raise e
|
|
56
|
+
end
|
|
57
|
+
end
|
|
32
58
|
end
|
|
33
59
|
|
|
34
60
|
def client
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: famoseagle-sweat_shop
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Amos Elliston
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-04-
|
|
12
|
+
date: 2009-04-15 00:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|