src/RequestHandler.php
public function tryOccupySlave(Slave $slave)
    {
        if ($slave->isExpired()) {
            $slave->close();
            $this->output->writeln(sprintf('Restart worker #%d because it reached its TTL', $slave->getPort()));
            $slave->getConnection()->close();
            return false;
        }

        $this->redirectionTries++;

        $this->slave = $slave;

        $this->verboseTimer(function ($took) {
            return sprintf('<info>took abnormal %.3f seconds for choosing next free worker</info>', $took);
        });

        // mark slave as busy
        $this->slave->occupy();

        $connector = new UnixConnector($this->loop);
        $connector = new TimeoutConnector($connector, $this->timeout, $this->loop);

        $socketPath = $this->getSlaveSocketPath($this->slave->getPort());
        $connector->connect($socketPath)->then(
            [$this, 'slaveConnected'],
            [$this, 'slaveConnectFailed']
        );
        return true;
    }
public function tryOccupySlave(Slave $slave)
    {
        if ($slave->isExpired()) {
            $slave->close();
            $this->output->writeln(sprintf('Restart worker #%d because it reached its TTL', $slave->getPort()));
            $slave->getConnection()->close();
            return false;
        }

        $this->redirectionTries++;

        $this->slave = $slave;

        $this->verboseTimer(function ($took) {
            return sprintf('<info>took abnormal %.3f seconds for choosing next free worker</info>', $took);
        });

        // mark slave as busy
        $this->slave->occupy();

        $connector = new UnixConnector($this->loop);
        $connector = new TimeoutConnector($connector, $this->timeout, $this->loop);

        $socketPath = $this->getSlaveSocketPath($this->slave->getPort());
        $connector->connect($socketPath)->then(
            [$this, 'slaveConnected'],
            [$this, 'slaveConnectFailed']
        );
        return true;
    }
public function tryOccupySlave ( Slave $ slave ) { if ( $ slave -> isExpired ( ) ) { $ slave -> close ( ) ; $ this -> output -> writeln ( sprintf ( 'Restart worker #%d because it reached its TTL' , $ slave -> getPort ( ) ) ) ; $ slave -> getConnection ( ) -> close ( ) ; return false ; } $ this -> redirectionTries ++ ; $ this -> slave = $ slave ; $ this -> verboseTimer ( function ( $ took ) { return sprintf ( '<info>took abnormal %.3f seconds for choosing next free worker</info>' , $ took ) ; } ) ; // mark slave as busy $ this -> slave -> occupy ( ) ; $ connector = new UnixConnector ( $ this -> loop ) ; $ connector = new TimeoutConnector ( $ connector , $ this -> timeout , $ this -> loop ) ; $ socketPath = $ this -> getSlaveSocketPath ( $ this -> slave -> getPort ( ) ) ; $ connector -> connect ( $ socketPath ) -> then ( [ $ this , 'slaveConnected' ] , [ $ this , 'slaveConnectFailed' ] ) ; return true ; }
Slave available handler

@param Slave $slave available slave instance
@return bool Slave is available
Slave available handler