amq-client 0.7.0.alpha9 → 0.7.0.alpha10

Sign up to get free protection for your applications and to get access to all the features.
@@ -146,6 +146,15 @@ module AMQ
146
146
  def async?
147
147
  !sync?
148
148
  end
149
+
150
+
151
+ # Can be overriden by higher-level libraries like amqp gem or bunny.
152
+ # Defaults to AMQ::Client::TCPConnectionFailed.
153
+ #
154
+ # @return [Exception]
155
+ def tcp_connection_failure_exception_class
156
+ @tcp_connection_failure_exception_class ||= AMQ::Client::TCPConnectionFailed
157
+ end # tcp_connection_failure_exception_class
149
158
  end # ClassMethods
150
159
 
151
160
 
@@ -24,6 +24,9 @@ module AMQ
24
24
  # API
25
25
  #
26
26
 
27
+ attr_reader :connections
28
+
29
+
27
30
  def self.connect(settings = nil, &block)
28
31
  @settings = Settings.configure(settings)
29
32
 
@@ -55,11 +58,57 @@ module AMQ
55
58
  EventMachine.reconnect(@settings[:host], @settings[:port], self)
56
59
  end
57
60
 
58
- # For EventMachine adapter, this is a no-op.
61
+
62
+ # Defines a callback that will be executed when AMQP connection is considered open,
63
+ # after client and broker has agreed on max channel identifier and maximum allowed frame
64
+ # size. You can define more than one callback.
65
+ #
66
+ # @see #on_open
59
67
  # @api public
60
- def establish_connection(settings)
61
- # Unfortunately there doesn't seem to be any sane way
62
- # how to get EventMachine connect to the instance level.
68
+ def on_connection(&block)
69
+ @connection_deferrable.callback(&block)
70
+ end # on_connection(&block)
71
+
72
+ # Defines a callback that will be executed when AMQP connection is considered open,
73
+ # before client and broker has agreed on max channel identifier and maximum allowed frame
74
+ # size. You can define more than one callback.
75
+ #
76
+ # @see #on_connection
77
+ # @api public
78
+ def on_open(&block)
79
+ @connection_opened_deferrable.callback(&block)
80
+ end # on_open(&block)
81
+
82
+ # Defines a callback that will be run when broker confirms connection termination
83
+ # (client receives connection.close-ok). You can define more than one callback.
84
+ #
85
+ # @api public
86
+ def on_disconnection(&block)
87
+ @disconnection_deferrable.callback(&block)
88
+ end # on_disconnection(&block)
89
+
90
+ # Defines a callback that will be run when initial TCP connection fails.
91
+ # You can define only one callback.
92
+ #
93
+ # @api public
94
+ def on_tcp_connection_failure(&block)
95
+ @on_tcp_connection_failure = block
96
+ end
97
+
98
+ # Defines a callback that will be run when initial TCP connection fails.
99
+ # You can define only one callback.
100
+ #
101
+ # @api public
102
+ def on_tcp_connection_loss(&block)
103
+ @on_tcp_connection_loss = block
104
+ end
105
+
106
+ # Defines a callback that will be run when TCP connection is closed before authentication
107
+ # finishes. Usually this means authentication failure. You can define only one callback.
108
+ #
109
+ # @api public
110
+ def on_possible_authentication_failure(&block)
111
+ @on_possible_authentication_failure = block
63
112
  end
64
113
 
65
114
  # @see #on_connection
@@ -76,9 +125,6 @@ module AMQ
76
125
  end
77
126
 
78
127
 
79
- attr_reader :connections
80
-
81
-
82
128
  def initialize(*args)
83
129
  super(*args)
84
130
 
@@ -93,7 +139,7 @@ module AMQ
93
139
  @settings = args.first
94
140
  @on_possible_authentication_failure = @settings[:on_possible_authentication_failure]
95
141
  @on_tcp_connection_failure = @settings[:on_tcp_connection_failure] || Proc.new { |settings|
96
- raise AMQ::Client::TCPConnectionFailed.new(settings)
142
+ raise self.class.tcp_connection_failure_exception_class.new(settings)
97
143
  }
98
144
 
99
145
  self.reset
@@ -125,6 +171,15 @@ module AMQ
125
171
  @tcp_connection_established
126
172
  end # tcp_connection_established?
127
173
 
174
+ # For EventMachine adapter, this is a no-op.
175
+ # @api public
176
+ def establish_connection(settings)
177
+ # Unfortunately there doesn't seem to be any sane way
178
+ # how to get EventMachine connect to the instance level.
179
+ end
180
+
181
+
182
+
128
183
  #
129
184
  # Implementation
130
185
  #
@@ -221,15 +276,6 @@ module AMQ
221
276
  end
222
277
  end
223
278
 
224
- # Defines a callback that will be executed when AMQP connection is considered open,
225
- # after client and broker has agreed on max channel identifier and maximum allowed frame
226
- # size. You can define more than one callback.
227
- #
228
- # @see #on_open
229
- # @api public
230
- def on_connection(&block)
231
- @connection_deferrable.callback(&block)
232
- end # on_connection(&block)
233
279
 
234
280
  # Called by AMQ::Client::Connection after we receive connection.open-ok.
235
281
  # @api public
@@ -238,16 +284,6 @@ module AMQ
238
284
  end # connection_successful
239
285
 
240
286
 
241
- # Defines a callback that will be executed when AMQP connection is considered open,
242
- # before client and broker has agreed on max channel identifier and maximum allowed frame
243
- # size. You can define more than one callback.
244
- #
245
- # @see #on_connection
246
- # @api public
247
- def on_open(&block)
248
- @connection_opened_deferrable.callback(&block)
249
- end # on_open(&block)
250
-
251
287
  # Called by AMQ::Client::Connection after we receive connection.tune.
252
288
  # @api public
253
289
  def open_successful
@@ -258,14 +294,6 @@ module AMQ
258
294
  end # open_successful
259
295
 
260
296
 
261
- # Defines a callback that will be run when broker confirms connection termination
262
- # (client receives connection.close-ok). You can define more than one callback.
263
- #
264
- # @api public
265
- def on_disconnection(&block)
266
- @disconnection_deferrable.callback(&block)
267
- end # on_disconnection(&block)
268
-
269
297
  # Called by AMQ::Client::Connection after we receive connection.close-ok.
270
298
  #
271
299
  # @api public
@@ -278,43 +306,16 @@ module AMQ
278
306
  end # disconnection_successful
279
307
 
280
308
 
281
- # Defines a callback that will be run when initial TCP connection fails.
282
- # You can define only one callback.
283
- #
284
- # @api public
285
- def on_tcp_connection_failure(&block)
286
- @on_tcp_connection_failure = block
287
- end
288
-
289
- # Called when initial TCP connection fails.
290
- # @api public
291
- def tcp_connection_failed
292
- @on_tcp_connection_failure.call(@settings) if @on_tcp_connection_failure
293
- end
294
-
295
-
296
- # Defines a callback that will be run when initial TCP connection fails.
297
- # You can define only one callback.
298
- #
299
- # @api public
300
- def on_tcp_connection_loss(&block)
301
- @on_tcp_connection_loss = block
302
- end
303
-
304
309
  # Called when initial TCP connection fails.
305
310
  # @api public
306
311
  def tcp_connection_lost
307
312
  @on_tcp_connection_loss.call(self, @settings) if @on_tcp_connection_loss
308
313
  end
309
314
 
310
-
311
-
312
- # Defines a callback that will be run when TCP connection is closed before authentication
313
- # finishes. Usually this means authentication failure. You can define only one callback.
314
- #
315
+ # Called when initial TCP connection fails.
315
316
  # @api public
316
- def on_possible_authentication_failure(&block)
317
- @on_possible_authentication_failure = block
317
+ def tcp_connection_failed
318
+ @on_tcp_connection_failure.call(@settings) if @on_tcp_connection_failure
318
319
  end
319
320
 
320
321
 
@@ -379,7 +380,7 @@ module AMQ
379
380
  elsif tls_options
380
381
  start_tls
381
382
  end
382
- end
383
+ end # upgrade_to_tls_if_necessary
383
384
  end # EventMachineClient
384
385
  end # Client
385
386
  end # AMQ
@@ -1,5 +1,5 @@
1
1
  module AMQ
2
2
  module Client
3
- VERSION = "0.7.0.alpha9"
3
+ VERSION = "0.7.0.alpha10"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amq-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0.alpha9
4
+ version: 0.7.0.alpha10
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -12,12 +12,12 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain:
15
- date: 2011-04-22 00:00:00.000000000 +04:00
15
+ date: 2011-04-23 00:00:00.000000000 +04:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: eventmachine
20
- requirement: &2152222340 !ruby/object:Gem::Requirement
20
+ requirement: &2152494160 !ruby/object:Gem::Requirement
21
21
  none: false
22
22
  requirements:
23
23
  - - ! '>='
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: '0'
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *2152222340
28
+ version_requirements: *2152494160
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: amq-protocol
31
- requirement: &2152457200 !ruby/object:Gem::Requirement
31
+ requirement: &2152717940 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ! '>='
@@ -36,7 +36,7 @@ dependencies:
36
36
  version: '0'
37
37
  type: :runtime
38
38
  prerelease: false
39
- version_requirements: *2152457200
39
+ version_requirements: *2152717940
40
40
  description: amq-client supports multiple networking adapters (EventMachine, TCP sockets,
41
41
  cool.io) and supposed to back more opinionated AMQP clients (such as amqp gem, bunny,
42
42
  et cetera) or be used directly in cases when access to more advanced AMQP 0.9.1