Kraken\Root\Runtime\Provider\ChannelProvider::applySimpleRouting PHP Method

applySimpleRouting() private method

private applySimpleRouting ( Kraken\Runtime\RuntimeContainerInterface $runtime, Kraken\Channel\ChannelCompositeInterface $composite )
$runtime Kraken\Runtime\RuntimeContainerInterface
$composite Kraken\Channel\ChannelCompositeInterface
    private function applySimpleRouting(RuntimeContainerInterface $runtime, ChannelCompositeInterface $composite)
    {
        $master = $composite->getBus('master');
        $slave = $composite->getBus('slave');
        $router = $composite->getInput();
        $router->addDefault(new RuleHandler(function ($params) {
            return true;
        }));
        $router = $composite->getOutput();
        $router->addDefault(function ($receiver, ProtocolInterface $protocol, $flags, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0) use($runtime, $slave, $master) {
            if ($runtime->getManager()->existsRuntime($receiver) || $slave->isConnected($receiver)) {
                $slave->push($receiver, $protocol, $flags, $success, $failure, $cancel, $timeout);
            } else {
                $master->push($runtime->getParent(), $protocol, $flags, $success, $failure, $cancel, $timeout);
            }
        });
        $router = $master->getInput();
        $router->addRule(new RuleMatchDestination($master->getName()), new RuleHandler(function ($params) use($runtime, $composite) {
            $this->executeProtocol($runtime, $composite, $params['protocol']);
        }));
        $router->addDefault(new RuleHandler(function ($params) use($slave) {
            $slave->push($slave->getConnected(), $params['protocol'], $params['flags']);
        }));
        $router = $slave->getInput();
        $router->addRule(new RuleMatchDestination($slave->getName()), new RuleHandler(function ($params) use($runtime, $composite) {
            $this->executeProtocol($runtime, $composite, $params['protocol']);
        }));
        $router->addDefault(new RuleHandler(function ($params) use($runtime, $slave, $master) {
            $master->push($runtime->getParent(), $params['protocol'], $params['flags']);
        }));
        $router = $master->getOutput();
        $router->addDefault(function ($sender, ProtocolInterface $protocol, $flags, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0) use($master) {
            $master->push($sender, $protocol, $flags, $success, $failure, $cancel, $timeout);
        });
        $router = $slave->getOutput();
        $router->addDefault(function ($sender, ProtocolInterface $protocol, $flags, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0) use($slave) {
            $slave->push($sender, $protocol, $flags, $success, $failure, $cancel, $timeout);
        });
    }