X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;f=includes%2Fjobqueue%2FJobQueueRedis.php;h=7dad014e45151c70d81b961c59ddae28932f476e;hb=4f31afd21b208965bae734396f6e2c6df06684c7;hp=990248a064da4a4abb1d5a28403f47803c2ebe87;hpb=507643bafe9b09ac3500cb1de617136110cdf55d;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/jobqueue/JobQueueRedis.php b/includes/jobqueue/JobQueueRedis.php index 990248a064..7dad014e45 100644 --- a/includes/jobqueue/JobQueueRedis.php +++ b/includes/jobqueue/JobQueueRedis.php @@ -18,8 +18,8 @@ * http://www.gnu.org/copyleft/gpl.html * * @file - * @author Aaron Schulz */ +use Psr\Log\LoggerInterface; /** * Class to handle job queues stored in Redis @@ -66,16 +66,15 @@ class JobQueueRedis extends JobQueue { /** @var RedisConnectionPool */ protected $redisPool; + /** @var LoggerInterface */ + protected $logger; /** @var string Server address */ protected $server; /** @var string Compression method to use */ protected $compression; - const MAX_AGE_PRUNE = 604800; // integer; seconds a job can live once claimed (7 days) - - /** @var string Key to prefix the queue keys with (used for testing) */ - protected $key; + const MAX_PUSH_SIZE = 25; // avoid tying up the server /** * @param array $params Possible keys: @@ -101,6 +100,7 @@ class JobQueueRedis extends JobQueue { "Non-daemonized mode is no longer supported. Please install the " . "mediawiki/services/jobrunner service and update \$wgJobTypeConf as needed." ); } + $this->logger = \MediaWiki\Logger\LoggerFactory::getInstance( 'redis' ); } protected function supportedOrders() { @@ -213,7 +213,7 @@ class JobQueueRedis extends JobQueue { if ( $flags & self::QOS_ATOMIC ) { $batches = [ $items ]; // all or nothing } else { - $batches = array_chunk( $items, 100 ); // avoid tying up the server + $batches = array_chunk( $items, self::MAX_PUSH_SIZE ); } $failed = 0; $pushed = 0; @@ -255,6 +255,7 @@ class JobQueueRedis extends JobQueue { $args[] = (string)$this->serialize( $item ); } static $script = + /** @lang Lua */ <<getConnection(); try { static $script = + /** @lang Lua */ <<redisPool->getConnection( $this->server ); + $conn = $this->redisPool->getConnection( $this->server, $this->logger ); if ( !$conn ) { throw new JobQueueConnectionError( "Unable to connect to redis server {$this->server}." ); @@ -791,9 +794,9 @@ LUA; private function getGlobalKey( $name ) { $parts = [ 'global', 'jobqueue', $name ]; foreach ( $parts as $part ) { - if ( !preg_match( '/[a-zA-Z0-9_-]+/', $part ) ) { - throw new InvalidArgumentException( "Key part characters are out of range." ); - } + if ( !preg_match( '/[a-zA-Z0-9_-]+/', $part ) ) { + throw new InvalidArgumentException( "Key part characters are out of range." ); + } } return implode( ':', $parts );