Class: Quark::Quark::Behaviors::RPCRequest
Constant Summary
DatawireQuarkCore::Static::Unassigned
Instance Attribute Summary collapse
Instance Method Summary
collapse
_lazy_statics, static, unlazy_statics
#to_s
Constructor Details
#initialize(args, rpc) ⇒ RPCRequest
Returns a new instance of RPCRequest.
221
222
223
224
225
226
227
228
229
230
|
# File 'lib/quark/behaviors.rb', line 221
def initialize(args, rpc)
self.__init_fields__
(self).retval = ::DatawireQuarkCore.cast((rpc).returned.construct(::DatawireQuarkCore::List.new([]))) { ::Quark.quark.concurrent.Future }
(self).args = args
(self).timeout = ::Quark.quark.concurrent.Timeout.new((rpc).timeout)
(self).rpc = rpc
nil
end
|
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
214
215
216
|
# File 'lib/quark/behaviors.rb', line 214
def args
@args
end
|
#retval ⇒ Object
Returns the value of attribute retval.
214
215
216
|
# File 'lib/quark/behaviors.rb', line 214
def retval
@retval
end
|
#rpc ⇒ Object
Returns the value of attribute rpc.
214
215
216
|
# File 'lib/quark/behaviors.rb', line 214
def rpc
@rpc
end
|
#timeout ⇒ Object
Returns the value of attribute timeout.
214
215
216
|
# File 'lib/quark/behaviors.rb', line 214
def timeout
@timeout
end
|
Instance Method Details
#__init_fields__ ⇒ Object
344
345
346
347
348
349
350
351
352
|
# File 'lib/quark/behaviors.rb', line 344
def __init_fields__()
self.rpc = nil
self.retval = nil
self.args = nil
self.timeout = nil
nil
end
|
#_getClass ⇒ Object
279
280
281
282
283
284
|
# File 'lib/quark/behaviors.rb', line 279
def _getClass()
return "quark.behaviors.RPCRequest"
nil
end
|
#_getField(name) ⇒ Object
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
|
# File 'lib/quark/behaviors.rb', line 286
def _getField(name)
if ((name) == ("rpc"))
return (self).rpc
end
if ((name) == ("retval"))
return (self).retval
end
if ((name) == ("args"))
return (self).args
end
if ((name) == ("timeout"))
return (self).timeout
end
return nil
nil
end
|
#_setField(name, value) ⇒ Object
#call(request) ⇒ Object
235
236
237
238
239
240
241
242
|
# File 'lib/quark/behaviors.rb', line 235
def call(request)
(self).timeout.start(self)
::Quark.quark.concurrent.Context.runtime().request(request, self)
return (self).retval
nil
end
|
#onHTTPError(request, message) ⇒ Object
330
331
332
333
334
335
|
# File 'lib/quark/behaviors.rb', line 330
def onHTTPError(request, message)
nil
nil
end
|
#onHTTPFinal(request) ⇒ Object
337
338
339
340
341
342
|
# File 'lib/quark/behaviors.rb', line 337
def onHTTPFinal(request)
nil
nil
end
|
#onHTTPInit(request) ⇒ Object
323
324
325
326
327
328
|
# File 'lib/quark/behaviors.rb', line 323
def onHTTPInit(request)
nil
nil
end
|
#onHTTPResponse(rq, response) ⇒ Object
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
# File 'lib/quark/behaviors.rb', line 244
def onHTTPResponse(rq, response)
info = nil
(self).timeout.cancel()
if ((response.getCode()) != (200))
info = (((self).rpc.toString()) + (" failed: Server returned error ")) + ((response.getCode()).to_s)
(self).retval.finish(::Quark.quark.behaviors.RPCError.new(info))
(self).rpc.fail(info)
return
end
body = response.getBody()
obj = ::DatawireQuarkCore::JSONObject.parse(body)
classname = (obj).getObjectItem("$class").getString()
if ((classname) == (nil))
info = ((self).rpc.toString()) + (" failed: Server returned unrecognizable content")
(self).retval.finish(::Quark.quark.behaviors.RPCError.new(info))
(self).rpc.fail(info)
return
else
::Quark.quark.fromJSON(((self).rpc).returned, (self).retval, obj)
(self).retval.finish(nil)
(self).rpc.succeed("Success in the future...")
end
nil
end
|
#onTimeout(timeout) ⇒ Object
271
272
273
274
275
276
277
|
# File 'lib/quark/behaviors.rb', line 271
def onTimeout(timeout)
(self).retval.finish(::Quark.quark.behaviors.RPCError.new("request timed out"))
(self).rpc.fail("request timed out")
nil
end
|