Exemplo n.º 1
0
 public function process()
 {
     $request = $this->node->request();
     if (!$request) {
         return true;
     }
     $requestKey = $request['key'];
     // Check the result data in the storage
     $data = $this->node->checkData($requestKey);
     if ($data) {
         $this->node->notify(json_encode(['data_key' => $requestKey, 'request_key' => $requestKey]));
         $this->logger->info('Result data found, notification sent', ['request_key' => $requestKey]);
         return true;
     }
     $request['key'] = $requestKey;
     $workload = json_encode($request);
     if (!$this->node->checkIndex($requestKey)) {
         $this->node->addToIndex($requestKey);
         $this->addTaskBackground($this->function, $workload);
         $this->logger->info('Task added', ['request_key' => $requestKey]);
     } else {
         $this->logger->info('Trying to add duplicate task', ['request_key' => $requestKey]);
     }
     return parent::process();
 }
Exemplo n.º 2
0
 public function process()
 {
     $request = $this->node->request();
     if ($request) {
         $this->handleRequest($request);
     }
     // Получаем уведомления от родительского узла
     $notify = $this->node->getNotify();
     // data_key & request_key
     if ($notify) {
         $this->handleNotify($notify);
     }
     return parent::process();
 }