public function run()
 {
     $id = array_shift($this->args);
     $this->out('Running ' . $id);
     if (Queue::run($id)) {
         $this->out('Success.');
         $this->out(Queue::view($id));
         $this->out();
     } else {
         $this->out('Failed to run task. Check logs.');
     }
 }
Esempio n. 2
0
 public function testDifferentCallbacks()
 {
     $type = 'test5';
     $dataIn1 = "testString1251in";
     $dataIn2 = "testString1252in";
     $dataOut1 = "testString1251out";
     $dataOut2 = "testString1252out";
     $runCallback1 = function (InputMessage $inputMessage) use($dataOut1) {
         return new OutputMessage($dataOut1);
     };
     $runCallback2 = function (InputMessage $inputMessage) use($dataOut2) {
         return new OutputMessage($dataOut2);
     };
     $inputMessage1 = new InputMessage($dataIn1);
     $identifier1 = $this->queueClient->submitInput($type, $inputMessage1);
     $this->queueServer->run($type, $runCallback1);
     $outputMessage1 = $this->queueClient->getOutput($type, $identifier1);
     $inputMessage2 = new InputMessage($dataIn2);
     $identifier2 = $this->queueClient->submitInput($type, $inputMessage2);
     $this->queueServer->run($type, $runCallback2);
     $outputMessage2 = $this->queueClient->getOutput($type, $identifier2);
     $this->assertEquals($dataOut1, $outputMessage1->getData());
     $this->assertEquals($dataOut2, $outputMessage2->getData());
 }
Esempio n. 3
0
    {
        $this->commands[] = $command;
    }
    public function run()
    {
        while (!is_null($command = $this->next())) {
            $command->execute();
        }
    }
    private function next()
    {
        if (count($this->commands) === 0 || count($this->commands) <= $this->current_index) {
            return null;
        } else {
            return $this->commands[$this->current_index++];
        }
    }
}
/**
 * Client
 */
$queue = new Queue();
//Invoker
$file = new File("sample.txt");
//Reciever
$queue->addCommand(new TouchCommand($file));
//Command
$queue->addCommand(new CompressCommand($file));
$queue->addCommand(new CopyCommand($file));
$queue->run();