public function run(PayloadInterface $payload)
 {
     $this->invoked = true;
     return parent::run($payload);
 }
Esempio n. 2
0
<?php

/*
 * This file is part of the andreas-weber/php-runner library.
 *
 * (c) Andreas Weber <*****@*****.**>
 *
 * This source file is subject to the MIT license that is bundled
 * with this source code in the file LICENSE.
 */
use AndreasWeber\Runner\Example\Task1;
use AndreasWeber\Runner\Example\Task2;
use AndreasWeber\Runner\Example\TaskFail;
use AndreasWeber\Runner\Payload\ArrayPayload;
use AndreasWeber\Runner\Runner;
use AndreasWeber\Runner\Task\Collection;
use AndreasWeber\Runner\Task\Retries\Retries;
require_once __DIR__ . '/../resources/bootstrap.php';
$collection = new Collection();
$collection->addTask(new Task1());
$collection->addTask(new Task2());
$retryTask = new TaskFail(2);
// task will fail 2 times, just for demonstration ;-)
$retryTask->setMaxRetries(new Retries(3));
// task will get retried 3 times
$collection->addTask($retryTask);
$payload = new ArrayPayload();
$runner = new Runner($collection, $logger);
$runner->run($payload);
// dump payload
var_export($payload);
Esempio n. 3
0
use AndreasWeber\Runner\Example\Task1;
use AndreasWeber\Runner\Example\Task2;
use AndreasWeber\Runner\Payload\ArrayPayload;
use AndreasWeber\Runner\Runner;
use AndreasWeber\Runner\Task\Collection;
require_once __DIR__ . '/../resources/bootstrap.php';
//
// Runner 1
//
$collection1 = new Collection();
$collection1->addTask(new Task1());
$collection1->addTask(new Task2());
$runner1 = new Runner($collection1, $logger);
//
// Runner 2
//
$collection2 = new Collection();
$collection2->addTask(new Task1());
$collection2->addTask(new Task2());
$runner2 = new Runner($collection2, $logger);
//
// Chaining
//
$runner1->attach($runner2);
//
// Invoke execution
//
$payload = new ArrayPayload();
$runner1->run($payload);
// dump payload
var_export($payload);