2017-07-15 20:44:06 +00:00
|
|
|
<?php
|
2017-11-17 01:23:18 +00:00
|
|
|
/** @license MIT
|
|
|
|
* Copyright 2017 J. King, Dustin Wilson et al.
|
|
|
|
* See LICENSE and AUTHORS files for details */
|
|
|
|
|
2017-07-15 20:44:06 +00:00
|
|
|
declare(strict_types=1);
|
|
|
|
namespace JKingWeb\Arsse\Service\Internal;
|
2017-08-29 14:50:31 +00:00
|
|
|
|
2017-07-17 11:47:57 +00:00
|
|
|
use JKingWeb\Arsse\Arsse;
|
2017-07-15 20:44:06 +00:00
|
|
|
|
|
|
|
class Driver implements \JKingWeb\Arsse\Service\Driver {
|
|
|
|
protected $queue = [];
|
2018-10-26 18:58:04 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public static function driverName(): string {
|
2017-07-17 11:47:57 +00:00
|
|
|
return Arsse::$lang->msg("Driver.Service.Internal.Name");
|
2017-07-15 20:44:06 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public static function requirementsMet(): bool {
|
2017-07-15 20:44:06 +00:00
|
|
|
// this driver has no requirements
|
|
|
|
return true;
|
|
|
|
}
|
2018-10-26 18:58:04 +00:00
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function __construct() {
|
2017-07-15 20:44:06 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function queue(int ...$feeds): int {
|
2017-07-15 20:44:06 +00:00
|
|
|
$this->queue = array_merge($this->queue, $feeds);
|
|
|
|
return sizeof($this->queue);
|
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function exec(): int {
|
|
|
|
while (sizeof($this->queue)) {
|
2017-07-15 20:44:06 +00:00
|
|
|
$id = array_shift($this->queue);
|
2017-07-17 11:47:57 +00:00
|
|
|
Arsse::$db->feedUpdate($id);
|
2017-07-15 20:44:06 +00:00
|
|
|
}
|
2017-07-17 11:47:57 +00:00
|
|
|
return Arsse::$conf->serviceQueueWidth - sizeof($this->queue);
|
2017-07-15 20:44:06 +00:00
|
|
|
}
|
|
|
|
|
2017-08-29 14:50:31 +00:00
|
|
|
public function clean(): bool {
|
2017-07-15 20:44:06 +00:00
|
|
|
$this->queue = [];
|
|
|
|
return true;
|
|
|
|
}
|
2017-08-29 14:50:31 +00:00
|
|
|
}
|