General developer forum

Enhancement to the Scheduled Tasks API to support 'random' time values

 
Dan at desk in Moodle HQ, Perth
Enhancement to the Scheduled Tasks API to support 'random' time values
Core developersMoodle Course Creator Certificate holdersMoodle HQPlugin developersTesters

Hi Everyone,

In MDL-47221 i've submitted a patch I am hoping to make into Moodle 2.8 to support random syntax in the scheduled task time definition. 

This is so you could put:

$tasks = array(
    array(
        'classname' => 'tool_langimport\task\update_langpacks_task',
        'blocking' => 0,
        'minute' => 'R',
        'hour' => '4',
        'day' => '*',
        'month' => '*',
        'dayofweek' => '*'
    )
);

And then the minute will be chosen at random at install time.

The point of this feature is so that you can create scheduled tasks which will not all run at the exact same time across different installs - its useful to stop overloading web-services. 

I intentionally restricted this syntax to time values, because I don't think it makes too much sense elsewhere (and also is tricky to compute :D).

I'd appreciate any comments/support/criticism of this patch on here or the issue!

cheers,

Dan

 
Average of ratings: -