Release of RC1 #7

Merged
abelhooge merged 34 commits from 3-features into master 2020-06-07 13:54:20 +00:00
5 changed files with 38 additions and 7 deletions
Showing only changes of commit b3982f2b2e - Show all commits

View File

@ -83,7 +83,7 @@ class ShellExecutor implements Executor
public function startTask(Task $task, bool $post = false): Task
{
// First prepare the command used to spawn workers
$commandString = "$this->binary $this->worker --bootstrap=".$this->bootstrapFile." -t %s ".($post ? 'p' : '')." $this->stdout $this->stderr & echo $!";
$commandString = "$this->binary $this->worker --bootstrap=".$this->bootstrapFile." -t %s ".($post ? '-p' : '')." $this->stdout $this->stderr & echo $!";
// Then execute the command using the base64_encoded string of the taskID
$output = $this->shellExec($commandString, [base64_encode($task->getId())]);

View File

@ -83,7 +83,7 @@ class ControllerHandler implements Handler
throw new TasksException("Could not handle task. Method '$this->controllerMethod' not found on controller.");
// Call method and collect output
$this->output = $controller->{$this->controllerMethod}(...$args);
$this->output = call_user_func_array([$controller, $this->controllerMethod], $args);
return true;
}
@ -102,7 +102,7 @@ class ControllerHandler implements Handler
public function postHandler(Task $task)
{
// Set the arguments
$args = $this->setArguments($task);
$this->setArguments($task);
// Abort if no postMethod exists
if (is_null($this->postMethod))
@ -116,7 +116,7 @@ class ControllerHandler implements Handler
throw new TasksException("Could not handle task. Post method '$this->postMethod' not found on controller.");
// Call method and collect output
$this->postOutput = $controller->{$this->postMethod}($task);
$this->postOutput = call_user_func_array([$controller, $this->postMethod], [$task]);
return true;
}
@ -135,11 +135,11 @@ class ControllerHandler implements Handler
* @return array
* @throws TasksException
*/
private function setArguments(Task $task): array
public function setArguments(Task $task): array
{
// Direct arguments
$args = $task->getArguments();
if (count($args) < 3)
if (count($args) < 2)
throw new TasksException("Could not handle task. Not enough arguments provided.");
// First argument: controllerName
@ -147,7 +147,7 @@ class ControllerHandler implements Handler
$this->controllerMethod = $args[1];
$this->postMethod = isset($args[2]) ? $args[2] : null;
return !isset($args[2]) ? [] : array_slice(func_get_args(), 3);
return !array_key_exists(2, $args) ? [] : array_slice($args, 3);
}
/**

View File

@ -152,4 +152,13 @@ interface TaskStorage
* @return array|null
*/
public function readPostOutput(Task $task, int $attempt = 0): ?array;
/**
* Reset the TaskStorage.
*
* Remove all tasks and their output from the storage so the TaskStorage begins anew.
*
* @return bool
*/
public function reset(): bool;
}

View File

@ -262,6 +262,15 @@ class ArrayTaskStorage implements TaskStorage
return ['output' => $data['output'], 'errors' => $data['errors'], 'statusCode' => $data['statusCode']];
}
/**
* @inheritDoc
*/
public function reset(): bool
{
// @todo Implement
return false;
}
private function commit()
{
$this->data = ['tasks' => []];

View File

@ -275,4 +275,17 @@ class RedisTaskStorage implements TaskStorage
return ['output' => $data['output'], 'errors' => $data['errors'], 'statusCode' => $data['statusCode']];
}
/**
* @inheritDoc
* @throws TasksException
*/
public function reset(): bool
{
// First get a list of all tasks
foreach ($this->readTasks() as $task)
$this->deleteTask($task);
return true;
}
}