/** * @param PromiseInterface $promise * @return PromiseInterface */ protected function send(PromiseInterface $promise) { $pid = $this->protocol->getPid(); $origin = $this->protocol->getOrigin(); $message = $this->message; $channel = $this->channel; if ($message instanceof Exception) { $answer = $channel->createProtocol($message->getMessage())->setPid($pid, true)->setException(get_class($message), true); } else { $answer = $channel->createProtocol($message)->setPid($pid, true); } $this->channel->send($origin, $answer, Channel::MODE_BUFFER_ONLINE); return $promise->resolve(); }
/** * @param PromiseInterface $promise * @return PromiseInterface */ protected function send(PromiseInterface $promise) { if (!$promise->isPending()) { return $promise; } $this->channel->send($this->name, $this->message, Channel::MODE_STANDARD, function ($value) use($promise) { $promise->resolve($value); }, function ($ex) use($promise) { $promise->reject($ex); }, function ($ex) use($promise) { $this->retryOrReset($promise, $ex); }, $this->params['timeout']); return $promise; }
/** * @param Error|Exception $ex * @param mixed[] $params * @return mixed */ protected function handler($ex, $params = []) { return $this->channel->send($params['origin'], new RuntimeCommand('container:continue')); }