* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @author Aaron Schulz
*/
+use Psr\Log\LoggerInterface;
/**
* Class to handle tracking information about all queues using PhpRedis
class JobQueueAggregatorRedis extends JobQueueAggregator {
/** @var RedisConnectionPool */
protected $redisPool;
+ /** @var LoggerInterface */
+ protected $logger;
/** @var array List of Redis server addresses */
protected $servers;
parent::__construct( $params );
$this->servers = isset( $params['redisServers'] )
? $params['redisServers']
- : array( $params['redisServer'] ); // b/c
+ : [ $params['redisServer'] ]; // b/c
$params['redisConfig']['serializer'] = 'none';
$this->redisPool = RedisConnectionPool::singleton( $params['redisConfig'] );
+ $this->logger = \MediaWiki\Logger\LoggerFactory::getInstance( 'redis' );
}
protected function doNotifyQueueEmpty( $wiki, $type ) {
protected function doGetAllReadyWikiQueues() {
$conn = $this->getConnection();
if ( !$conn ) {
- return array();
+ return [];
}
try {
$map = $conn->hGetAll( $this->getReadyQueueKey() );
if ( is_array( $map ) && isset( $map['_epoch'] ) ) {
unset( $map['_epoch'] ); // ignore
- $pendingDBs = array(); // (type => list of wikis)
+ $pendingDBs = []; // (type => list of wikis)
foreach ( $map as $key => $time ) {
list( $type, $wiki ) = $this->decodeQueueName( $key );
$pendingDBs[$type][] = $wiki;
} catch ( RedisException $e ) {
$this->redisPool->handleError( $conn, $e );
- return array();
+ return [];
}
}
protected function getConnection() {
$conn = false;
foreach ( $this->servers as $server ) {
- $conn = $this->redisPool->getConnection( $server );
+ $conn = $this->redisPool->getConnection( $server, $this->logger );
if ( $conn ) {
break;
}
/**
* @param string $name
- * @return string
+ * @return string[]
*/
private function decodeQueueName( $name ) {
list( $type, $wiki ) = explode( '/', $name, 2 );
- return array( rawurldecode( $type ), rawurldecode( $wiki ) );
+ return [ rawurldecode( $type ), rawurldecode( $wiki ) ];
}
}