public function onSuccessfulRequest(PostRequestSendEvent $event) { $request = $event->getRequest(); $this->fails[$request->getConnection()] = null; $this->slavesUsed = []; $this->masterUsed = null; if ($request->hasQueryMode()) { if ($request->getQueryMode() === 'WRITE') { $master = $this->connectionManager->getMasterConnection()->getAlias(); if ($request->getConnection() === $master) { $slaves = $this->connectionManager->getSlaves(); $slave = current($slaves); $this->writeReplicationUsed[] = $slave; Client::log('debug', sprintf('Performing write replication on connection "%s"', $slave)); $request->setInfoFromConnection($this->connectionManager->getConnection($slave)); $event->stopPropagation(); } elseif ($this->connectionManager->hasNextSlave($this->writeReplicationUsed)) { $next = $this->connectionManager->getNextSlave($this->writeReplicationUsed); $nc = $this->connectionManager->getConnection($next); Client::log('debug', sprintf('Performing write replication on connection "%s"', $next)); $request->setInfoFromConnection($nc); $event->stopPropagation(); } elseif (null !== $this->masterUsed && !$this->connectionManager->hasNextSlave($this->masterUsed) && $request->getConnection() !== $master) { $this->masterUsed = []; Client::log('debug', 'Replication terminated'); } } } }
/** * @param \Neoxygen\NeoClient\Event\PostRequestSendEvent $event */ public function onSuccessfulRequest(PostRequestSendEvent $event) { $request = $event->getRequest(); $this->fails[$request->getConnection()] = null; $this->slavesUsed = []; $this->masterUsed = null; }