/** * @param ChannelBaseInterface $channel * @param string $name * @param string|ChannelProtocolInterface $message * @param mixed[] $params */ public function __construct($channel, $name, $message, $params = []) { $this->channel = $channel; $this->name = $name; $this->message = $message instanceof ChannelProtocolInterface ? $message : $this->channel->createProtocol($message); $this->params = ['timeout' => isset($params['timeout']) ? $params['timeout'] : 3.0, 'retriesLimit' => isset($params['retriesLimit']) ? $params['retriesLimit'] : 6, 'retriesInterval' => isset($params['retriesInterval']) ? $params['retriesInterval'] : 2.0]; $this->counter = 1; $this->message->setTimestamp(TimeSupport::now() + ($this->params['retriesInterval'] + $this->params['timeout']) * 1000.0 * $this->params['retriesLimit'], true); }
/** * @param string|null $commandParent * @param string $commandName * @param string[] $commandParams * @return PromiseInterface */ public function handle($commandParent, $commandName, $commandParams = []) { $protocol = $this->channel->createProtocol(new RuntimeCommand($commandName, $commandParams)); if ($commandParent !== null) { $protocol->setDestination($commandParent); } $req = new Request($this->channel, $this->receiver, $protocol, ['timeout' => 2, 'retriesLimit' => 10, 'retriesInterval' => 1]); return $req->call(); }