1
1
Fork 0

Refactor deprecated App - process methods to DI::process()->*()

This commit is contained in:
Philipp Holzer 2019-12-16 00:33:35 +01:00
parent aedbdc536a
commit 5609e94b05
No known key found for this signature in database
GPG key ID: D8365C3D36B77D90
3 changed files with 8 additions and 33 deletions

View file

@ -13,12 +13,10 @@ use Friendica\Core\Config\Cache\ConfigCache;
use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Core\Theme;
use Friendica\Database\Database;
use Friendica\Model\Profile;
use Friendica\Module\Security\Login;
use Friendica\Module\Special\HTTPException as ModuleHTTPException;
use Friendica\Network\HTTPException;
use Friendica\Util\ConfigFileLoader;
@ -356,30 +354,6 @@ class App
$this->getBaseURL();
}
/**
* @deprecated 2019.09 - use Core\Process->isMaxProcessesReached() instead
*/
public function isMaxProcessesReached()
{
return $this->process->isMaxProcessesReached();
}
/**
* @deprecated 2019.09 - use Core\Process->isMinMemoryReached() instead
*/
public function isMinMemoryReached()
{
return $this->process->isMinMemoryReached();
}
/**
* @deprecated 2019.09 - use Core\Process->isMaxLoadReached() instead
*/
public function isMaxLoadReached()
{
return $this->process->isMaxLoadReached();
}
/**
* Generates the site's default sender email address
*

View file

@ -56,7 +56,7 @@ class Worker
self::$up_start = microtime(true);
// At first check the maximum load. We shouldn't continue with a high load
if ($a->isMaxLoadReached()) {
if (DI::process()->isMaxLoadReached()) {
Logger::log('Pre check: maximum load reached, quitting.', Logger::DEBUG);
return;
}
@ -78,7 +78,7 @@ class Worker
}
// Do we have too few memory?
if ($a->isMinMemoryReached()) {
if (DI::process()->isMinMemoryReached()) {
Logger::log('Pre check: Memory limit reached, quitting.', Logger::DEBUG);
return;
}
@ -90,7 +90,7 @@ class Worker
}
// Possibly there are too much database processes that block the system
if ($a->isMaxProcessesReached()) {
if (DI::process()->isMaxProcessesReached()) {
Logger::log('Pre check: maximum processes reached, quitting.', Logger::DEBUG);
return;
}
@ -140,7 +140,7 @@ class Worker
}
// Check free memory
if ($a->isMinMemoryReached()) {
if (DI::process()->isMinMemoryReached()) {
Logger::log('Memory limit reached, quitting.', Logger::DEBUG);
Lock::release('worker');
return;
@ -251,8 +251,6 @@ class Worker
*/
public static function execute($queue)
{
$a = \get_app();
$mypid = getmypid();
// Quit when in maintenance
@ -262,7 +260,7 @@ class Worker
}
// Constantly check the number of parallel database processes
if ($a->isMaxProcessesReached()) {
if (DI::process()->isMaxProcessesReached()) {
Logger::log("Max processes reached for process ".$mypid, Logger::DEBUG);
return false;
}

View file

@ -8,6 +8,7 @@ use Friendica\Core\Config\Configuration;
use Friendica\Core\Config\PConfiguration;
use Friendica\Core\L10n\L10n;
use Friendica\Core\Lock\ILock;
use Friendica\Core\Process;
use Friendica\Core\Session\ISession;
use Friendica\Database\Database;
use Friendica\Model\Notify;
@ -51,6 +52,7 @@ use Psr\Log\LoggerInterface;
* @method static App\Router router()
* @method static Database dba()
* @method static FileSystem fs()
* @method static Process process()
*
*/
class DI
@ -82,6 +84,7 @@ class DI
'dba' => Database::class,
'fs' => FileSystem::class,
'profiler' => Profiler::class,
'process' => Process::class,
];
/** @var Dice */