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

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

        $masterConnection = $connectionFactory->create(array(
            'host' => $replication['master_host'],
            'port' => $replication['master_port'],
            'alias' => 'master',
        ));

        $this->add($masterConnection);

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

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

        $masterConnection = $connectionFactory->create(array(
            'host' => $replication['master_host'],
            'port' => $replication['master_port'],
            'alias' => 'master',
        ));

        $this->add($masterConnection);

        $this->discoverFromMaster($masterConnection, $connectionFactory);
    }
protected function discoverFromSlave ( NodeConnectionInterface $ connection , FactoryInterface $ connectionFactory ) { $ response = $ connection -> executeCommand ( RawCommand :: create ( 'INFO' , 'REPLICATION' ) ) ; $ replication = $ this -> handleInfoResponse ( $ response ) ; if ( $ replication [ 'role' ] !== 'slave' ) { throw new ClientException ( "Role mismatch (expected slave, got master) [$connection]" ) ; } $ masterConnection = $ connectionFactory -> create ( array ( 'host' => $ replication [ 'master_host' ] , 'port' => $ replication [ 'master_port' ] , 'alias' => 'master' , ) ) ; $ this -> add ( $ masterConnection ) ; $ this -> discoverFromMaster ( $ masterConnection , $ connectionFactory ) ; }
Discovers the replication configuration by contacting one of the slaves.

@param NodeConnectionInterface $connection        Connection to one of the slaves.
@param FactoryInterface        $connectionFactory Connection factory instance.
Discovers the replication configuration by contacting one of the slaves .