Beispiel #1
0
 async def msg_get_query(self, msg):
     if msg.qid in self.subs:
         raise SubscriptionInUseError()
     if not msg.sub:
         checks = [] if msg.trace else None
         try:
             result = await self.conn.get_query_raw(msg.node, msg.query,
                                                    msg.params, checks)
         except VelesException as err:
             self.send_msg(
                 messages.MsgQueryError(
                     qid=msg.qid,
                     err=err,
                     checks=checks or [],
                 ))
         else:
             self.send_msg(
                 messages.MsgGetQueryReply(
                     qid=msg.qid,
                     result=result,
                     checks=checks or [],
                 ))
     else:
         self.subs[msg.qid] = SubscriberQuery(self.conn, msg.node,
                                              msg.query, msg.params,
                                              msg.trace, self, msg.qid)
Beispiel #2
0
 async def msg_get_data(self, msg):
     if msg.qid in self.subs:
         raise SubscriptionInUseError()
     if not msg.sub:
         try:
             data = await self.conn.get_data(msg.id, msg.key)
         except VelesException as err:
             self.send_msg(messages.MsgQueryError(
                 qid=msg.qid,
                 err=err,
             ))
         else:
             self.send_msg(messages.MsgGetDataReply(qid=msg.qid, data=data))
     else:
         self.subs[msg.qid] = SubscriberData(self.conn, msg.id, msg.key,
                                             self, msg.qid)
Beispiel #3
0
 async def msg_get(self, msg):
     if msg.qid in self.subs:
         raise SubscriptionInUseError()
     if not msg.sub:
         try:
             node = await self.conn.get(msg.id)
         except VelesException as err:
             self.send_msg(messages.MsgQueryError(
                 qid=msg.qid,
                 err=err,
             ))
         else:
             self.send_msg(messages.MsgGetReply(
                 qid=msg.qid,
                 obj=node,
             ))
     else:
         self.subs[msg.qid] = SubscriberNode(self.conn, msg.id, self,
                                             msg.qid)
Beispiel #4
0
 async def msg_list_connections(self, msg):
     if msg.qid in self.subs:
         raise SubscriptionInUseError()
     if not msg.sub:
         try:
             connections = await self.conn.get_connections()
         except VelesException as err:
             self.send_msg(messages.MsgQueryError(
                 qid=msg.qid,
                 err=err,
             ))
         else:
             self.send_msg(messages.MsgConnectionsReply(
                 qid=msg.qid,
                 connections=connections,
             ))
     else:
         self.subs[msg.qid] = SubscriberConnections(
             self.conn, self, msg.qid)
Beispiel #5
0
 async def msg_get_list(self, msg):
     if msg.qid in self.subs:
         raise SubscriptionInUseError()
     if not msg.sub:
         try:
             objs = await self.conn.get_list(
                 msg.parent, msg.tags, msg.pos_filter)
         except VelesException as err:
             self.send_msg(messages.MsgQueryError(
                 qid=msg.qid,
                 err=err,
             ))
         else:
             self.send_msg(messages.MsgGetListReply(
                 qid=msg.qid,
                 objs=objs,
             ))
     else:
         self.subs[msg.qid] = SubscriberList(
             self.conn, msg.parent, msg.tags, msg.pos_filter, self, msg.qid)
Beispiel #6
0
 async def msg_plugin_trigger_register(self, msg):
     if msg.phid in self.phids:
         raise SubscriptionInUseError()
     handler = RemoteTriggerHandler(msg.name, msg.tags, self, msg.phid)
     self.phids[msg.phid] = handler
     self.conn.register_trigger_handler(handler)
Beispiel #7
0
 async def msg_plugin_broadcast_register(self, msg):
     if msg.phid in self.phids:
         raise SubscriptionInUseError()
     handler = RemoteBroadcastHandler(msg.name, self, msg.phid)
     self.phids[msg.phid] = handler
     self.conn.register_plugin_handler(handler)