isono 0.2.19 → 0.2.20

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8e391d773178beebfa4cdf0598a13c124503b6a6
4
- data.tar.gz: 49f3936da23b3b20b240872da2fc726b93f973e4
3
+ metadata.gz: 1e666f9b342338026fe08b4880bf74dfb60673f8
4
+ data.tar.gz: a1127479b2ad3c83acff866011b1eaee1286907e
5
5
  SHA512:
6
- metadata.gz: 1d833c4e1f3c140eb2ef10c4bb6d558fb331fad5a10dc713b2767cd5875604fceb67189f0aaf9cedafdd20384128ee5503ca5c8960828f6bbb11f19f1981e858
7
- data.tar.gz: 7fb2a1785b15a094ad935f523b35efb442351ae720b2e4ba8aa595c96355a77660e0c99bd9c164234197fc220fcfd88d2688c04fd74ac4160741d1fb8dc45356
6
+ metadata.gz: 6271d86c5ec057bf267a3bc4322f19fdc83187d9ae1635691757a878688a66c67fa2a00d099cf9c3d7347feecd8e7ba99c3caec1d3f8522c76226a8f8af0a79c
7
+ data.tar.gz: 7ce671336b7e6bb8db77aaa8782445ce15ba1920f90ece1ce7cdf5edde5374697f0080995b9df0df64756bd7b4a42f8e0351e8d40f24da87276f0f282f864461
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "isono"
5
- s.version = "0.2.19"
5
+ s.version = "0.2.20"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["axsh Ltd.", "Masahiro Fujiwara"]
@@ -105,7 +105,7 @@ module Isono
105
105
  attr_reader :amq
106
106
 
107
107
  # Make a RPC request to an endpoint.
108
- #
108
+ #
109
109
  # @param [String] endpoint
110
110
  # @param [String] command
111
111
  # @param [Array] args
@@ -125,7 +125,7 @@ module Isono
125
125
  # }
126
126
  #
127
127
  # @example setup request context and do wait().
128
- # Note that callbacks are
128
+ # Note that callbacks are
129
129
  # rpc.request('endpoint1', 'func1', xxxx) { |req|
130
130
  # # send new attribute
131
131
  # req.request[:xxxx] = "sdfsdf"
@@ -133,7 +133,7 @@ module Isono
133
133
  # req.synchronize
134
134
  # }.wait # request() get back the altered RequestCotenxt that has wait().
135
135
  #
136
- # @example Create async oneshot call. (do not expect response)
136
+ # @example Create async oneshot call. (do not expect response)
137
137
  # rpc.request('endpoint1', 'func1') { |req|
138
138
  # req.oneshot = true
139
139
  # }
@@ -141,7 +141,7 @@ module Isono
141
141
  req = RequestContext.new(endpoint, command, args)
142
142
  # the block is to setup the request context prior to sending.
143
143
  if blk
144
- # async
144
+ # async
145
145
  r = blk.call(req)
146
146
  req = r if r.is_a?(RequestContext)
147
147
  send_request(req)
@@ -165,7 +165,7 @@ module Isono
165
165
  def register_endpoint(endpoint, app, opts={})
166
166
  raise TypeError unless app.respond_to?(:call)
167
167
  opts = {:exclusive=>true, :prefetch=>1}.merge(opts)
168
-
168
+
169
169
  # create receive queue for new RPC endpoint.
170
170
  endpoint_proc = proc { |header, data|
171
171
 
@@ -188,7 +188,7 @@ module Isono
188
188
  end
189
189
  }
190
190
 
191
-
191
+
192
192
  EventMachine.schedule {
193
193
  ch = node.create_channel
194
194
 
@@ -215,7 +215,7 @@ module Isono
215
215
  end
216
216
 
217
217
  # Unregister endpoint.
218
- #
218
+ #
219
219
  # @param [String] endpoint endpoint name to be removed
220
220
  def unregister_endpoint(endpoint)
221
221
  if @endpoints.has_key?(endpoint)
@@ -228,7 +228,7 @@ module Isono
228
228
  }
229
229
  end
230
230
  end
231
-
231
+
232
232
  private
233
233
  def endpoint_queue_name(ns)
234
234
  "isono.rpc.endpoint.#{ns}"
@@ -253,9 +253,9 @@ module Isono
253
253
  # set default timeout if no one updated the initial value.
254
254
  req.timeout_sec = config_section.timeout_sec
255
255
  end
256
-
256
+
257
257
  req.process_event(:on_ready)
258
-
258
+
259
259
  EventMachine.schedule {
260
260
  @stats[:total_request_count] += 1
261
261
  if @stats[:peak_wait_response_size] < @active_requests.size
@@ -281,7 +281,7 @@ module Isono
281
281
 
282
282
  class ResponseContext
283
283
  attr_reader :header
284
-
284
+
285
285
  def initialize(exchange, header)
286
286
  @responded = false
287
287
  @exchange = exchange
@@ -342,6 +342,8 @@ module Isono
342
342
  attr_reader :error_cb, :success_cb, :progress_cb
343
343
  attr_reader :state
344
344
 
345
+ include Isono::Logger
346
+
345
347
  def initialize(endpoint, command, args)
346
348
  super({:request=>{
347
349
  :endpoint=> endpoint,
@@ -355,7 +357,7 @@ module Isono
355
357
  :completed_at => nil,
356
358
  :complete_status => nil,
357
359
  })
358
-
360
+
359
361
  @success_cb = nil
360
362
  @progress_cb = nil
361
363
  @error_cb = nil
@@ -432,10 +434,11 @@ module Isono
432
434
  module RequestSynchronize
433
435
  def self.extended(mod)
434
436
  raise TypeError, "This module is applicable only for RequestContext" unless mod.is_a?(RequestContext)
437
+
435
438
  # overwrite callbacks
436
439
  mod.instance_eval {
437
440
  @q = ::Queue.new
438
-
441
+
439
442
  on_success { |r|
440
443
  @q << [:success, r]
441
444
  }
@@ -447,11 +450,15 @@ module Isono
447
450
 
448
451
  public
449
452
  def wait()
450
- raise "response was received already." if state == :done
451
453
  raise "wait() has to be called at outside of the EventMachine's main loop." if EventMachine.reactor_thread?
452
-
454
+ if state == :done && @q.empty?
455
+ logger.warn "Remote procedure call state is 'done' and response queue is empty. " +
456
+ "May be waiting forever for a response. Endpoint: '%s' Command: '%s'" %
457
+ [endpoint, command]
458
+ end
459
+
453
460
  r = @q.deq
454
-
461
+
455
462
  case r[0]
456
463
  when :success
457
464
  r[1]
@@ -460,9 +467,9 @@ module Isono
460
467
  end
461
468
  end
462
469
  end
463
-
470
+
464
471
  end
465
-
472
+
466
473
  end
467
474
  end
468
475
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isono
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.19
4
+ version: 0.2.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - axsh Ltd.