Class: Isono::NodeModules::RpcChannel::ResponseContext

Inherits:
Object
  • Object
show all
Defined in:
lib/isono/node_modules/rpc_channel.rb

Direct Known Subclasses

OneshotResponseContext

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(exchange, header) ⇒ ResponseContext

Returns a new instance of ResponseContext.



285
286
287
288
289
# File 'lib/isono/node_modules/rpc_channel.rb', line 285

def initialize(exchange, header)
  @responded = false
  @exchange = exchange
  @header = header
end

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



283
284
285
# File 'lib/isono/node_modules/rpc_channel.rb', line 283

def header
  @header
end

Instance Method Details

#progress(ret) ⇒ Object



295
296
297
298
299
# File 'lib/isono/node_modules/rpc_channel.rb', line 295

def progress(ret)
  EM.schedule {
    publish(:inprogress, ret)
  }
end

#responded?Boolean

Returns:

  • (Boolean)


291
292
293
# File 'lib/isono/node_modules/rpc_channel.rb', line 291

def responded?
  @responded
end

#response(ret) ⇒ Object



301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/isono/node_modules/rpc_channel.rb', line 301

def response(ret)
  raise "" if @responded

  EM.schedule {
    @header.ack
    if ret.is_a? Exception
      publish(:error, {:message=> ret.message, :error_type => ret.class.to_s})
    else
      publish(:success, ret)
    end
  }
  @responded = true
end