def delegate(self, args, callback):
     print('delegating to the callback method')
     #for example for kafka, start the consumer here that listens on certain topic
     newArgs = Args()
     newArgs.timestamp = time.time()
     newArgs.requestid = 'abc'
     newArgs.data = 'data'
     callback(newArgs)
Example #2
0
 def delegate(self, args, callback):
     print('delegating to the callback method')
     #sends message whenever message is received
     for message in self.consumer:
         #print("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition, message.offset, message.key, message.value))
         newArgs = Args() #other args
         newArgs.name = self.name
         newArgs.timestamp = time.time()
         newArgs.requestid = 'abc'
         newArgs.topic = message.topic
         newArgs.partition = message.partition
         newArgs.offset = message.offset
         newArgs.key = message.key
         newArgs.value = message.value
          
         nnDataBase = NNImageData(message.key, message.value, newArgs) #key and value are standard data for this
         callback(nnDataBase)