[PLUGINS] Added UnQueue, a new default plugin which does all actions immediately

This commit is contained in:
Miguel Dantas 2019-09-01 00:40:33 +01:00 committed by Diogo Peralta Cordeiro
parent 333b915740
commit 7cdd64f594
5 changed files with 66 additions and 12 deletions

View File

@ -59,18 +59,9 @@ abstract class QueueManager extends IoManager
if (empty(self::$qm)) { if (empty(self::$qm)) {
if (Event::handle('StartNewQueueManager', array(&self::$qm))) { if (Event::handle('StartNewQueueManager', array(&self::$qm))) {
$enabled = common_config('queue', 'enabled'); common_log(LOG_ERR, 'Some form of queue manager must be active' .
$type = common_config('queue', 'subsystem'); '(UnQueue does everything immediately and is the default)');
throw new ServerException('Some form of queue manager must be active');
if (!$enabled) {
// does everything immediately
self::$qm = new UnQueueManager();
} else {
switch ($type) {
default:
throw new ServerException("No queue manager class for type '$type'");
}
}
} }
} }

View File

@ -361,6 +361,7 @@ $default =
'Poll' => [], 'Poll' => [],
'SimpleCaptcha' => [], 'SimpleCaptcha' => [],
'TagSub' => [], 'TagSub' => [],
'UnQueue' => [],
'WebFinger' => [], 'WebFinger' => [],
], ],
'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories 'locale_path' => false, // Set to a path to use *instead of* each plugin's own locale subdirectories

14
plugins/UnQueue/README Normal file
View File

@ -0,0 +1,14 @@
UnQueuePlugin wraps the UnQueueManager class which is a queue manager that does all work immediately.
Installation
============
This plugin is enabled by default and cannot be disabled unless another queue manager is in use.
Disabling is not necessary but recommended in such cases.
Example
=======
In config.php
addPlugin('UnQueue');

View File

@ -0,0 +1,48 @@
<?php
// This file is part of GNU social - https://www.gnu.org/software/social
//
// GNU social is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// GNU social is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>.
/**
* Immediate action queue
*
* @package GNUsocial
* @author Miguel Dantas <biodantasgs@gmail.com>
* @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
* @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
*/
defined('GNUSOCIAL') || die();
class UnQueuePlugin extends Plugin
{
const PLUGIN_VERSION = '0.0.1';
public function onStartNewQueueManager(?QueueManager &$qm)
{
$qm = new UnQueueManager();
return false;
}
public function onPluginVersion(array &$versions): bool
{
$versions[] = array('name' => 'UnQueue',
'version' => self::PLUGIN_VERSION,
'author' => 'Miguel Dantas',
'description' =>
// TRANS: Plugin description.
_m('Plugin using the database as a backend for GNU social queues'));
return true;
}
};