qsagi 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c6c1657688bf4b0e502f6874a2b3e1138b12cd12
4
- data.tar.gz: ee0f8fbe53ebfbf3dfbc6fdbd3dd77d2cf477284
3
+ metadata.gz: 0e63068ac04b6c2610b9074ca57bad759440561e
4
+ data.tar.gz: c4389fddd23a9f52af347bd57c429fda80fccb01
5
5
  SHA512:
6
- metadata.gz: 3dabe240665ede31c347b4f50a55f02f0b3a7287c2a82f0841313c05d7b5cc176bd1a08d18b9599647d657539c783817c13d129ef63b46c13d835ab7ba73447b
7
- data.tar.gz: a7002edd8ecd4cbd4de8a6f504705f12bbb2ac7f4d6bd214e0f62a4b388e8ee133403e4dd713ba308029035b3d55ff807338eb365505f43dde314a8493942490
6
+ metadata.gz: 2c1b947ae6081e99b830b696fe631d3694c640d6ed5819c9b94b3dde8d24e748675f7b27a26c9612cf934a017b42e87229473f12209a07e9b1c31cc7aa5bf9aa
7
+ data.tar.gz: c6e2aed327af4af1a98841a357e504c454b9fceed864e67b9ee6e85ab36c5f6a544f1461de6acbb4e27901b97413e53b56e0f33b0e16fe040f6502ebd351fb61
@@ -1,3 +1,5 @@
1
+ require 'thread'
2
+
1
3
  module Qsagi
2
4
  class ConfirmedQueue
3
5
  attr_reader :nacked_messages
@@ -7,6 +9,7 @@ module Qsagi
7
9
  @nacked_messages = []
8
10
  @unconfirmed_messages = {}
9
11
  @wait_for_confirms = false
12
+ @semaphore = Mutex.new
10
13
  end
11
14
 
12
15
  def connect
@@ -19,7 +22,10 @@ module Qsagi
19
22
  end
20
23
 
21
24
  def push(message)
22
- @unconfirmed_messages[_channel.next_publish_seq_no] = message
25
+ next_sequence_number = _channel.next_publish_seq_no
26
+ @semaphore.synchronize do
27
+ @unconfirmed_messages[next_sequence_number] = message
28
+ end
23
29
  @queue.push(message)
24
30
  @wait_for_confirms = true
25
31
  end
@@ -54,9 +60,13 @@ module Qsagi
54
60
  end
55
61
 
56
62
  def _confirm_select
57
- _channel.confirm_select lambda { |delivery_tag, multiple, is_nack|
58
- _confirm_messages!(:delivery_tag => delivery_tag, :multiple => multiple, :is_nack => is_nack)
59
- }
63
+ callback = lambda do |delivery_tag, multiple, is_nack|
64
+ @semaphore.synchronize do
65
+ _confirm_messages!(:delivery_tag => delivery_tag, :multiple => multiple, :is_nack => is_nack)
66
+ end
67
+ end
68
+
69
+ _channel.confirm_select(callback)
60
70
  end
61
71
 
62
72
  def _wait_for_confirms?
@@ -1,3 +1,3 @@
1
1
  module Qsagi
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qsagi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Braintree
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-19 00:00:00.000000000 Z
11
+ date: 2017-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -94,3 +94,4 @@ test_files:
94
94
  - spec/qsagi/message_spec.rb
95
95
  - spec/qsagi/queue_spec.rb
96
96
  - spec/spec_helper.rb
97
+ has_rdoc: