def subscribe(self, key, dataindex, corrId="", callback=None, pull=False, interval=30, args={}): """Subscribe to a DATAINDEX for a given KEY.""" self.log_info("subscribed to %s with dataindex %s", key, dataindex) msg = d6message.d6msg(key=key, replyTo=self.name, correlationId=corrId, dataindex=dataindex, body=args) if pull: msg.type = 'pull' else: msg.type = 'sub' corruuid = msg.correlationId self.subdata[corruuid] = dataobj.subData(key, dataindex, corruuid, callback) self.scheduuids.add(corruuid) self.schedule(msg, corruuid, interval) return corruuid
def request(self, key, dataindex, corrId="", callback=None, interval=0, timer=30, args={}): msg = d6message.d6msg(key=key, replyTo=self.name, correlationId=corrId, type="req", dataindex=dataindex, body=args) corruuid = msg.correlationId self.subdata[corruuid] = dataobj.subData(key, dataindex, corruuid, callback) if interval: self.scheduuids.add(corruuid) self.schedule(msg, corruuid, interval, callback) else: self.send(msg) if timer: self.timerThreads.append( eventlet.spawn_after(timer, self.reqtimeout, corruuid))
def command( self, key, command, corrId="", callback=None, timer=30, args={}): msg = d6message.d6msg(key=key, replyTo=self.name, type="cmd", correlationId=corrId, dataindex=command, body=args) corruuid = msg.correlationId self.subdata[corruuid] = dataobj.subData(key, command, corruuid, callback) self.send(msg) if timer: self.timerThreads.append( eventlet.spawn_after(timer, self.reqtimeout, corruuid))
def subscribe( self, key, dataindex, corrId="", callback=None, pull=False, interval=30, args={}): """Subscribe to a DATAINDEX for a given KEY.""" self.log_debug("subscribed to %s with dataindex %s", key, dataindex) msg = d6message.d6msg(key=key, replyTo=self.name, correlationId=corrId, dataindex=dataindex, body=args) if pull: msg.type = 'pull' else: msg.type = 'sub' corruuid = msg.correlationId self.subdata[corruuid] = dataobj.subData(key, dataindex, corruuid, callback) self.scheduuids.add(corruuid) self.schedule(msg, corruuid, interval) return corruuid
def request( self, key, dataindex, corrId="", callback=None, interval=0, timer=30, args={}): msg = d6message.d6msg(key=key, replyTo=self.name, correlationId=corrId, type="req", dataindex=dataindex, body=args) corruuid = msg.correlationId self.subdata[corruuid] = dataobj.subData(key, dataindex, corruuid, callback) if interval: self.scheduuids.add(corruuid) self.schedule(msg, corruuid, interval, callback) else: self.send(msg) if timer: self.timerThreads.append( eventlet.spawn_after(timer, self.reqtimeout, corruuid))
def command(self, key, command, corrId="", callback=None, timer=30, args={}): msg = d6message.d6msg(key=key, replyTo=self.name, type="cmd", correlationId=corrId, dataindex=command, body=args) corruuid = msg.correlationId self.subdata[corruuid] = dataobj.subData(key, command, corruuid, callback) self.send(msg) if timer: self.timerThreads.append( eventlet.spawn_after(timer, self.reqtimeout, corruuid))