Exemple #1
0
 def on_reply(self, document):
     """
     Handle the reply.
     :param document: The reply document.
     :type document: Document
     :return: The matched reply document.
     :rtype: Document
     """
     reply = Return(document.result)
     if reply.succeeded():
         return reply.retval
     else:
         raise RemoteException.instance(reply)
Exemple #2
0
 def on_reply(self, document):
     """
     Handle the reply.
     :param document: The reply document.
     :type document: Document
     :return: The matched reply document.
     :rtype: Document
     """
     reply = Return(document.result)
     if reply.succeeded():
         return reply.retval
     else:
         raise RemoteException.instance(reply)
Exemple #3
0
class Call(Controller):
    def POST(self, uuid, cls, method):
        reply = {}
        httpcode = 200
        try:
            body = self.body()
            options = Option(body.options)
            options = options.valid()
            request = Request(body.request)
            request = request.valid()
            replyto = ReplyTo(body.replyto)
            replyto = replyto.valid()
            any = body.any
            agent = AgentImpl(uuid, options)
            reply = agent.call(cls, method, request, replyto, any)
            if replyto:
                httpcode = 202  # accepted
        except EXCEPTIONS, raised:
            httpcode = status(raised)
            reply = Return.exception()
            reply = exdict(raised, reply)
        except Exception, raised:
            httpcode = 500
            reply = Return.exception()
            reply = exdict(raised, reply)
Exemple #4
0
 def __init__(self, document):
     """
     :param document: The received document.
     :type document: Document
     """
     AsyncReply.__init__(self, document)
     reply = Return(document.result)
     self.retval = reply.retval
Exemple #5
0
 def __init__(self, document):
     """
     :param document: The received document.
     :type document: Document
     """
     AsyncReply.__init__(self, document)
     reply = Return(document.result)
     self.exval = RemoteException.instance(reply)
     self.xmodule = reply.xmodule,
     self.xclass = reply.xclass
     self.xstate = reply.xstate
     self.xargs = reply.xargs
Exemple #6
0
 def __sendreply(self, je):
     """
     Send the (timeout) reply to the I{replyto} AMQP address
     specified in the journal entry.
     @param je: A journal entry.
     @type je: Entry
     """
     sn = je.sn
     replyto = je.replyto
     any = je.any
     result = Return.exception()
     log.info('send (timeout) for sn:%s to:%s', sn, replyto)
     self.__producer.send(
         replyto,
         sn=sn,
         any=any,
         result=result,
         watchdog=self.__producer.uuid)
Exemple #7
0
 def POST(self, uuid, cls, method):
     reply = {}
     httpcode = 200
     try:
         body = self.body()
         options = Option(body.options)
         options = options.valid()
         request = Request(body.request)
         request = request.valid()
         replyto = ReplyTo(body.replyto)
         replyto = replyto.valid()
         any = body.any
         agent = AgentImpl(uuid, options)
         reply = agent.call(cls, method, request, replyto, any)
         if replyto:
             httpcode = 202 # accepted
     except EXCEPTIONS, raised:
         httpcode = status(raised)
         reply = Return.exception()
         reply = exdict(raised, reply)
Exemple #8
0
 def __call__(self, *args, **options):
     """
     Dispatch received request.
     """
     envelope = self.envelope
     try:
         self.expired()
         self.windowmissed()
         self.sendstarted(envelope)
         self.context.progress = Progress(self)
         result = self.plugin.dispatch(envelope)
         self.commit(envelope.sn)
         self.sendreply(envelope, result)
     except Expired:
         self.commit(envelope.sn)
         log.info("expired:\n%s", envelope)
     except WindowMissed:
         self.commit(envelope.sn)
         log.info("window missed:\n%s", envelope)
         self.sendreply(envelope, Return.exception())