famoseagle-sweat_shop 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/VERSION.yml +1 -1
  2. data/lib/message_queue/rabbit.rb +33 -7
  3. metadata +2 -2
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :patch: 0
3
3
  :major: 0
4
- :minor: 5
4
+ :minor: 6
@@ -10,25 +10,51 @@ module MessageQueue
10
10
  end
11
11
 
12
12
  def delete(queue)
13
- client.queue(queue).delete
13
+ send_command do
14
+ client.queue(queue).delete
15
+ end
14
16
  end
15
17
 
16
18
  def queue_size(queue)
17
- client.queue(queue).message_count
19
+ send_command do
20
+ client.queue(queue).message_count
21
+ end
18
22
  end
19
23
 
20
24
  def enqueue(queue, data)
21
- client.queue(queue, :durable => true).publish(Marshal.dump(data), :persistent => true)
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
- task = client.queue(queue).pop(:ack => true)
26
- return unless task
27
- Marshal.load(task)
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
- client.queue(queue).ack
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.5.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 00:00:00 -07:00
12
+ date: 2009-04-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15