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.



251
252
253
254
255
# File 'lib/isono/node_modules/rpc_channel.rb', line 251

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

Instance Attribute Details

#headerObject (readonly)

Returns the value of attribute header.



249
250
251
# File 'lib/isono/node_modules/rpc_channel.rb', line 249

def header
  @header
end

Instance Method Details

#progress(ret) ⇒ Object



261
262
263
264
265
# File 'lib/isono/node_modules/rpc_channel.rb', line 261

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

#responded?Boolean

Returns:

  • (Boolean)


257
258
259
# File 'lib/isono/node_modules/rpc_channel.rb', line 257

def responded?
  @responded
end

#response(ret) ⇒ Object



267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/isono/node_modules/rpc_channel.rb', line 267

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