MediaWiki master
RedisPubSubFeedEngine.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\RCFeed;
22
24
51
58 public function send( array $feed, $line ) {
59 $parsed = wfParseUrl( $feed['uri'] );
60 $server = $parsed['host'];
61 $options = [ 'serializer' => 'none' ];
62 $channel = 'rc';
63
64 if ( isset( $parsed['port'] ) ) {
65 $server .= ":{$parsed['port']}";
66 }
67 if ( isset( $parsed['query'] ) ) {
68 parse_str( $parsed['query'], $options );
69 }
70 if ( isset( $parsed['pass'] ) ) {
71 $options['password'] = $parsed['pass'];
72 }
73 if ( isset( $parsed['path'] ) ) {
74 $channel = str_replace( '/', '.', ltrim( $parsed['path'], '/' ) );
75 }
76 $pool = RedisConnectionPool::singleton( $options );
77 $conn = $pool->getConnection( $server );
78 if ( $conn !== false ) {
79 $conn->publish( $channel, $line );
80 return true;
81 }
82
83 return false;
84 }
85}
87class_alias( RedisPubSubFeedEngine::class, 'RedisPubSubFeedEngine' );
wfParseUrl( $url)
parse_url() work-alike, but non-broken.
Base class for RCFeed implementations that use RCFeedFormatter.
Send recent change to a Redis Pub/Sub channel.
Helper class to manage Redis connections.