Chainedtask order #69
Replies: 5 comments 16 replies
-
Hi @jvancoillie 👋🏻 That's an ... interesting point that you're mentioning here 😄 At the beginning of the development of this bundle, the feature was present then ... I remove it for some random reasons, by default, tasks are executed in the order defined in the configuration file (no matter the format). We can sort the tasks using |
Beta Was this translation helpful? Give feedback.
-
Hi @Guikingone, I have just set up an environment to study the bundle and see how we could deal with the notion of priority. I realize that the order of the configuration of the task is not that which one finds at the execution, therefore it seems important to me to introduce the notion of priority. my yaml configuration : scheduler_bundle:
transport:
# dsn: 'filesystem://first_in_first_out'
dsn: 'doctrine://default?execution_mode=first_in_first_out'
tasks:
world:
type: 'command'
command: 'app:world'
expression: '* * * * *'
description: 'world command'
hello:
type: 'command'
command: 'app:hello'
expression: '* * * * *'
description: 'hello command' the the we can see that the order of execution is not the same as the configuration. in both transports How do you see priority management ? |
Beta Was this translation helpful? Give feedback.
-
Is a simple sorting on the priority of the tasks sufficient or should there be an execution mode for the 'chained' type that could orchestrate the list. if a simple sort is sufficient, is it preferable to sort the tasks at the build of the chainedTask /**
* {@inheritdoc}
*/
public function build(PropertyAccessorInterface $propertyAccessor, array $options = []): TaskInterface
{
$tasks = array_map(function (array $task) use ($propertyAccessor): TaskInterface {
foreach ($this->builders as $builder) {
if (!$builder->support($task['type'])) {
continue;
}
return $builder->build($propertyAccessor, $task);
}
throw new InvalidArgumentException('The given task cannot be created as no related builder can be found');
}, $options['tasks']);
uasort($tasks, fn (TaskInterface $task, TaskInterface $nextTask): int => $task->getPriority() <=> $nextTask->getPriority());
$chainedTask = new ChainedTask($options['name'], ...$tasks);
unset($options['tasks']);
return $this->handleTaskAttributes($chainedTask, $options, $propertyAccessor);
} or at each call of the getTasks() method /**
* @return TaskInterface[]
*/
public function getTasks(): array
{
uasort($this->options['tasks'], fn (TaskInterface $task, TaskInterface $nextTask): int => $task->getPriority() <=> $nextTask->getPriority());
return $this->options['tasks'];
} |
Beta Was this translation helpful? Give feedback.
-
I have proposed a pull request, can I integrate the PriorityPolicy on it or should I create a new one? With this policy we could set it to a chained type by default. I'm wondering about the validation of the configuration, currently there is no validation on the |
Beta Was this translation helpful? Give feedback.
-
Hi @jvancoillie 👋🏻 Are we good with this discussion? 🤔 |
Beta Was this translation helpful? Give feedback.
-
How does the scheduling of a chainedtask work ?
According to the order defined in the yaml configuration ?
Can we use the priority configuration entry to order the chained tasks ?
Beta Was this translation helpful? Give feedback.
All reactions