public function executeInstruction(Instruction $instruction, bool $instructionShouldBeLogged = true)
    {
        // Check the process status because it could have crash in idle status.
        $this->checkProcessStatus();

        $serializedInstruction = json_encode($instruction);

        if ($instructionShouldBeLogged) {
            $this->logger->debug('Sending an instruction to the port {port}...', [
                'pid' => $this->processPid,
                'port' => $this->serverPort(),

                // The instruction must be fully encoded and decoded to appear properly in the logs (this way,
                // JS functions and resources are serialized too).
                'instruction' => json_decode($serializedInstruction, true),
            ]);
        }

        $this->client->selectWrite(1);
        $this->client->write($serializedInstruction);

        $value = $this->readNextProcessValue($instructionShouldBeLogged);

        // Check the process status if the value is null because, if the process crash while executing the instruction,
        // the socket closes and returns an empty value (which is converted to `null`).
        if ($value === null) {
            $this->checkProcessStatus();
        }

        return $value;
    }
public function executeInstruction(Instruction $instruction, bool $instructionShouldBeLogged = true)
    {
        // Check the process status because it could have crash in idle status.
        $this->checkProcessStatus();

        $serializedInstruction = json_encode($instruction);

        if ($instructionShouldBeLogged) {
            $this->logger->debug('Sending an instruction to the port {port}...', [
                'pid' => $this->processPid,
                'port' => $this->serverPort(),

                // The instruction must be fully encoded and decoded to appear properly in the logs (this way,
                // JS functions and resources are serialized too).
                'instruction' => json_decode($serializedInstruction, true),
            ]);
        }

        $this->client->selectWrite(1);
        $this->client->write($serializedInstruction);

        $value = $this->readNextProcessValue($instructionShouldBeLogged);

        // Check the process status if the value is null because, if the process crash while executing the instruction,
        // the socket closes and returns an empty value (which is converted to `null`).
        if ($value === null) {
            $this->checkProcessStatus();
        }

        return $value;
    }
public function executeInstruction ( Instruction $ instruction , bool $ instructionShouldBeLogged = true ) { // Check the process status because it could have crash in idle status. $ this -> checkProcessStatus ( ) ; $ serializedInstruction = json_encode ( $ instruction ) ; if ( $ instructionShouldBeLogged ) { $ this -> logger -> debug ( 'Sending an instruction to the port {port}...' , [ 'pid' => $ this -> processPid , 'port' => $ this -> serverPort ( ) , // The instruction must be fully encoded and decoded to appear properly in the logs (this way, // JS functions and resources are serialized too). 'instruction' => json_decode ( $ serializedInstruction , true ) , ] ) ; } $ this -> client -> selectWrite ( 1 ) ; $ this -> client -> write ( $ serializedInstruction ) ; $ value = $ this -> readNextProcessValue ( $ instructionShouldBeLogged ) ; // Check the process status if the value is null because, if the process crash while executing the instruction, // the socket closes and returns an empty value (which is converted to `null`). if ( $ value === null ) { $ this -> checkProcessStatus ( ) ; } return $ value ; }
Send an instruction to the process for execution.
Send an instruction to the process for execution .