Kraken\Root\Runtime\Provider\ChannelProvider::executeProtocol PHP Метод

executeProtocol() приватный Метод

private executeProtocol ( Kraken\Runtime\RuntimeContainerInterface $runtime, Kraken\Channel\ChannelCompositeInterface $composite, Kraken\Channel\Protocol\ProtocolInterface $protocol )
$runtime Kraken\Runtime\RuntimeContainerInterface
$composite Kraken\Channel\ChannelCompositeInterface
$protocol Kraken\Channel\Protocol\ProtocolInterface
    private function executeProtocol(RuntimeContainerInterface $runtime, ChannelCompositeInterface $composite, ProtocolInterface $protocol)
    {
        /**
         * If the json_decode fails, it means the received message is leftover of request response,
         * hence it should be dropped.
         */
        try {
            $params = json_decode($protocol->getMessage(), true);
            $command = array_shift($params);
            $params['origin'] = $protocol->getOrigin();
            if (!$runtime->isFailed() || isset($params['hash']) && $runtime->getHash() === $params['hash']) {
                $promise = $this->executeCommand($command, $params);
            } else {
                $promise = Promise::doReject(new RejectionException('Container is currently in failed state and cannot execute any tasks.'));
            }
            if ($protocol->getType() === Channel::TYPE_REQ) {
                $promise->then(function ($response) use($composite, $protocol, $command) {
                    return (new Response($composite, $protocol, $response))->call();
                }, function ($reason) use($composite, $protocol) {
                    return (new Response($composite, $protocol, $reason))->call();
                }, function ($reason) use($composite, $protocol) {
                    return (new Response($composite, $protocol, $reason))->call();
                });
            }
        } catch (Error $ex) {
            return;
        } catch (Exception $ex) {
            return;
        }
    }