src/Connection/Aggregate/MasterSlaveReplication.php
protected function discoverFromMaster(NodeConnectionInterface $connection, FactoryInterface $connectionFactory)
    {
        $response = $connection->executeCommand(RawCommand::create('INFO', 'REPLICATION'));
        $replication = $this->handleInfoResponse($response);

        if ($replication['role'] !== 'master') {
            throw new ClientException("Role mismatch (expected master, got slave) [$connection]");
        }

        $this->slaves = array();

        foreach ($replication as $k => $v) {
            $parameters = null;

            if (strpos($k, 'slave') === 0 && preg_match('/ip=(?P<host>.*),port=(?P<port>\d+)/', $v, $parameters)) {
                $slaveConnection = $connectionFactory->create(array(
                    'host' => $parameters['host'],
                    'port' => $parameters['port'],
                ));

                $this->add($slaveConnection);
            }
        }
    }
protected function discoverFromMaster(NodeConnectionInterface $connection, FactoryInterface $connectionFactory)
    {
        $response = $connection->executeCommand(RawCommand::create('INFO', 'REPLICATION'));
        $replication = $this->handleInfoResponse($response);

        if ($replication['role'] !== 'master') {
            throw new ClientException("Role mismatch (expected master, got slave) [$connection]");
        }

        $this->slaves = array();

        foreach ($replication as $k => $v) {
            $parameters = null;

            if (strpos($k, 'slave') === 0 && preg_match('/ip=(?P<host>.*),port=(?P<port>\d+)/', $v, $parameters)) {
                $slaveConnection = $connectionFactory->create(array(
                    'host' => $parameters['host'],
                    'port' => $parameters['port'],
                ));

                $this->add($slaveConnection);
            }
        }
    }
protected function discoverFromMaster ( NodeConnectionInterface $ connection , FactoryInterface $ connectionFactory ) { $ response = $ connection -> executeCommand ( RawCommand :: create ( 'INFO' , 'REPLICATION' ) ) ; $ replication = $ this -> handleInfoResponse ( $ response ) ; if ( $ replication [ 'role' ] !== 'master' ) { throw new ClientException ( "Role mismatch (expected master, got slave) [$connection]" ) ; } $ this -> slaves = array ( ) ; foreach ( $ replication as $ k => $ v ) { $ parameters = null ; if ( strpos ( $ k , 'slave' ) === 0 && preg_match ( '/ip=(?P<host>.*),port=(?P<port>\d+)/' , $ v , $ parameters ) ) { $ slaveConnection = $ connectionFactory -> create ( array ( 'host' => $ parameters [ 'host' ] , 'port' => $ parameters [ 'port' ] , ) ) ; $ this -> add ( $ slaveConnection ) ; } } }
Discovers the replication configuration by contacting the master node.

@param NodeConnectionInterface $connection        Connection to the master node.
@param FactoryInterface        $connectionFactory Connection factory instance.
Discovers the replication configuration by contacting the master node .