tmm1-amqp 0.6.1 → 0.6.3
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/amqp.gemspec +1 -1
- data/lib/amqp.rb +4 -1
- data/lib/amqp/client.rb +28 -7
- data/lib/ext/emfork.rb +1 -1
- data/lib/mq.rb +5 -1
- metadata +1 -1
data/amqp.gemspec
CHANGED
data/lib/amqp.rb
CHANGED
data/lib/amqp/client.rb
CHANGED
@@ -9,7 +9,7 @@ module AMQP
|
|
9
9
|
mq.process_frame(frame)
|
10
10
|
return
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
case frame
|
14
14
|
when Frame::Method
|
15
15
|
case method = frame.payload
|
@@ -49,7 +49,7 @@ module AMQP
|
|
49
49
|
def self.client
|
50
50
|
@client ||= BasicClient
|
51
51
|
end
|
52
|
-
|
52
|
+
|
53
53
|
def self.client= mod
|
54
54
|
mod.__send__ :include, AMQP
|
55
55
|
@client = mod
|
@@ -66,22 +66,34 @@ module AMQP
|
|
66
66
|
|
67
67
|
timeout @settings[:timeout] if @settings[:timeout]
|
68
68
|
errback{ @on_disconnect.call } unless @reconnecting
|
69
|
+
|
70
|
+
@connected = false
|
69
71
|
end
|
70
72
|
|
71
73
|
def connection_completed
|
74
|
+
start_tls if @settings[:ssl]
|
72
75
|
log 'connected'
|
73
76
|
# @on_disconnect = proc{ raise Error, 'Disconnected from server' }
|
74
77
|
unless @closing
|
75
|
-
@on_disconnect = method(:
|
78
|
+
@on_disconnect = method(:disconnected)
|
76
79
|
@reconnecting = false
|
77
80
|
end
|
81
|
+
|
82
|
+
@connected = true
|
83
|
+
@connection_status.call(:connected) if @connection_status
|
84
|
+
|
78
85
|
@buf = Buffer.new
|
79
86
|
send_data HEADER
|
80
87
|
send_data [1, 1, VERSION_MAJOR, VERSION_MINOR].pack('C4')
|
81
88
|
end
|
82
89
|
|
90
|
+
def connected?
|
91
|
+
@connected
|
92
|
+
end
|
93
|
+
|
83
94
|
def unbind
|
84
95
|
log 'disconnected'
|
96
|
+
@connected = false
|
85
97
|
EM.next_tick{ @on_disconnect.call }
|
86
98
|
end
|
87
99
|
|
@@ -95,7 +107,7 @@ module AMQP
|
|
95
107
|
def channels
|
96
108
|
@channels ||= {}
|
97
109
|
end
|
98
|
-
|
110
|
+
|
99
111
|
def receive_data data
|
100
112
|
# log 'receive_data', data
|
101
113
|
@buf << data
|
@@ -110,7 +122,7 @@ module AMQP
|
|
110
122
|
# this is a stub meant to be
|
111
123
|
# replaced by the module passed into initialize
|
112
124
|
end
|
113
|
-
|
125
|
+
|
114
126
|
def send data, opts = {}
|
115
127
|
channel = opts[:channel] ||= 0
|
116
128
|
data = data.to_frame(channel) unless data.is_a? Frame
|
@@ -176,9 +188,18 @@ module AMQP
|
|
176
188
|
opts = AMQP.settings.merge(opts)
|
177
189
|
EM.connect opts[:host], opts[:port], self, opts
|
178
190
|
end
|
179
|
-
|
191
|
+
|
192
|
+
def connection_status &blk
|
193
|
+
@connection_status = blk
|
194
|
+
end
|
195
|
+
|
180
196
|
private
|
181
|
-
|
197
|
+
|
198
|
+
def disconnected
|
199
|
+
@connection_status.call(:disconnected) if @connection_status
|
200
|
+
reconnect
|
201
|
+
end
|
202
|
+
|
182
203
|
def log *args
|
183
204
|
return unless @settings[:logging] or AMQP.logging
|
184
205
|
require 'pp'
|
data/lib/ext/emfork.rb
CHANGED
data/lib/mq.rb
CHANGED
@@ -145,7 +145,7 @@ class MQ
|
|
145
145
|
send Protocol::Channel::Open.new
|
146
146
|
}
|
147
147
|
end
|
148
|
-
attr_reader :channel
|
148
|
+
attr_reader :channel, :connection
|
149
149
|
|
150
150
|
# May raise a MQ::Error exception when the frame payload contains a
|
151
151
|
# Protocol::Channel::Close object.
|
@@ -732,6 +732,10 @@ class MQ
|
|
732
732
|
end
|
733
733
|
end
|
734
734
|
|
735
|
+
def prefetch(size)
|
736
|
+
send Protocol::Basic::Qos.new(:prefetch_size => 0, :prefetch_count => size, :global => false)
|
737
|
+
end
|
738
|
+
|
735
739
|
# Returns a hash of all the exchange proxy objects.
|
736
740
|
#
|
737
741
|
# Not typically called by client code.
|