MDL-74843 tasks: Deprecation \core\task\manager::ensure_adhoc_task_qos
Signed-off-by: Daniel Ziegenberg <[email protected]>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
issueNumber: MDL-74843
|
||||
notes:
|
||||
core:
|
||||
- message: 'Final deprecation of \core\task\manager::ensure_adhoc_task_qos()'
|
||||
type: removed
|
||||
@@ -664,83 +664,11 @@ class manager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure quality of service for the ad hoc task queue.
|
||||
*
|
||||
* This reshuffles the adhoc tasks queue to balance by type to ensure a
|
||||
* level of quality of service per type, while still maintaining the
|
||||
* relative order of tasks queued by timestamp.
|
||||
*
|
||||
* @param array $records array of task records
|
||||
* @param array $records array of same task records shuffled
|
||||
* @deprecated since Moodle 4.1 MDL-67648 - please do not use this method anymore.
|
||||
* @todo MDL-74843 This method will be deleted in Moodle 4.5
|
||||
* @see \core\task\manager::get_next_adhoc_task
|
||||
* @deprecated since Moodle 4.1 MDL-67648
|
||||
*/
|
||||
public static function ensure_adhoc_task_qos(array $records): array {
|
||||
debugging('The method \core\task\manager::ensure_adhoc_task_qos is deprecated.
|
||||
Please use \core\task\manager::get_next_adhoc_task instead.', DEBUG_DEVELOPER);
|
||||
|
||||
$count = count($records);
|
||||
if ($count == 0) {
|
||||
return $records;
|
||||
}
|
||||
|
||||
$queues = []; // This holds a queue for each type of adhoc task.
|
||||
$limits = []; // The relative limits of each type of task.
|
||||
$limittotal = 0;
|
||||
|
||||
// Split the single queue up into queues per type.
|
||||
foreach ($records as $record) {
|
||||
$type = $record->classname;
|
||||
if (!array_key_exists($type, $queues)) {
|
||||
$queues[$type] = [];
|
||||
}
|
||||
if (!array_key_exists($type, $limits)) {
|
||||
$limits[$type] = 1;
|
||||
$limittotal += 1;
|
||||
}
|
||||
$queues[$type][] = $record;
|
||||
}
|
||||
|
||||
$qos = []; // Our new queue with ensured quality of service.
|
||||
$seed = $count % $limittotal; // Which task queue to shuffle from first?
|
||||
|
||||
$move = 1; // How many tasks to shuffle at a time.
|
||||
do {
|
||||
$shuffled = 0;
|
||||
|
||||
// Now cycle through task type queues and interleaving the tasks
|
||||
// back into a single queue.
|
||||
foreach ($limits as $type => $limit) {
|
||||
|
||||
// Just interleaving the queue is not enough, because after
|
||||
// any task is processed the whole queue is rebuilt again. So
|
||||
// we need to deterministically start on different types of
|
||||
// tasks so that *on average* we rotate through each type of task.
|
||||
//
|
||||
// We achieve this by using a $seed to start moving tasks off a
|
||||
// different queue each time. The seed is based on the task count
|
||||
// modulo the number of types of tasks on the queue. As we count
|
||||
// down this naturally cycles through each type of record.
|
||||
if ($seed < 1) {
|
||||
$shuffled = 1;
|
||||
$seed += 1;
|
||||
continue;
|
||||
}
|
||||
$tasks = array_splice($queues[$type], 0, $move);
|
||||
$qos = array_merge($qos, $tasks);
|
||||
|
||||
// Stop if we didn't move any tasks onto the main queue.
|
||||
$shuffled += count($tasks);
|
||||
}
|
||||
// Generally the only tasks that matter are those that are near the start so
|
||||
// after we have shuffled the first few 1 by 1, start shuffling larger groups.
|
||||
if (count($qos) >= (4 * count($limits))) {
|
||||
$move *= 2;
|
||||
}
|
||||
} while ($shuffled > 0);
|
||||
|
||||
return $qos;
|
||||
#[\core\attribute\deprecated('\core\task\manager::get_next_adhoc_task()', since: '4.1', mdl: 'MDL-67648', final: true)]
|
||||
public static function ensure_adhoc_task_qos(): void {
|
||||
\core\deprecation::emit_deprecation_if_present([self::class, __FUNCTION__]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -515,7 +515,7 @@ being forced open in all behat tests.
|
||||
- upgrade_analytics_fix_contextids_defaults()
|
||||
- upgrade_convert_hub_config_site_param_names()
|
||||
- upgrade_rename_prediction_actions_useful_incorrectly_flagged()
|
||||
* The method ensure_adhoc_task_qos() in lib/classes/task/manager.php has been deprecated, please use get_next_adhoc_task()
|
||||
* The method ensure_adhoc_task_qos() in lib/classes/task/manager.php has been deprecated, please use get_next_adhoc_task()
|
||||
instead.
|
||||
* New setting $CFG->enrolments_sync_interval controls the minimum time in seconds between re-synchronization of enrollment via enrol_check_plugins.
|
||||
This only applies to web requests without a session such as webservice calls, tokenpluginfile.php and rss links Function
|
||||
|
||||
Reference in New Issue
Block a user