3 * StatusNet - the distributed open-source microblogging tool
4 * Copyright (C) 2011, StatusNet, Inc.
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Affero General Public License for more details.
18 * You should have received a copy of the GNU Affero General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 * @category OpportunisticQMPlugin
23 * @author Brion Vibber <brion@status.net>
24 * @copyright 2011 StatusNet, Inc.
25 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html AGPL 3.0
26 * @link http://status.net/
29 class OpportunisticQMPlugin extends Plugin {
30 public $qmkey = false;
31 public $secs_per_action = 1; // total seconds to run script per action
32 public $rel_to_pageload = true; // relative to pageload or queue start
34 public function onRouterInitialized(URLMapper $m)
36 $m->connect('main/runqueue', array('action' => 'runqueue'));
40 * When the page has finished rendering, let's do some cron jobs
41 * if we have the time.
43 public function onEndActionExecute(Action $action)
45 if ($action instanceof RunqueueAction) {
52 'qmkey' => common_config('opportunisticqm', 'qmkey'),
53 'max_execution_time' => $this->secs_per_action,
54 'started_at' => $this->rel_to_pageload ? $_startTime : null,
56 $qm = new OpportunisticQueueManager($args);
61 public function onPluginVersion(array &$versions)
63 $versions[] = array('name' => 'OpportunisticQM',
64 'version' => GNUSOCIAL_VERSION,
65 'author' => 'Mikael Nordfeldth',
66 'homepage' => 'http://www.gnu.org/software/social/',
68 // TRANS: Plugin description.
69 _m('Opportunistic queue manager plugin for background processing.'));