You are browsing a read-only backup copy of Wikitech. The primary site can be found at

RCStream: Difference between revisions

From Wikitech-static
Jump to navigation Jump to search
(BryanDavis moved page RCStream to Obsolete:RCStream: Moving decomissed service docs to Obsolete namespace)
Line 1: Line 1:
[[File:RCStream example.png|thumb|374px|link=|Example client at []]]
#REDIRECT [[Obsolete:RCStream]]
|text=This service has been '''deprecated''' in favor of [[EventStreams]], available at [].  As of 2017-07-10, RCStream is offline, and will no longer serve events.
'''RCStream''' is a simple server daemon that broadcasts "recent changes" events from MediaWiki wikis using the [ Socket.IO] 0.9 protocol. The main instance used to run at <code></code>, broadcasting changes from all public wikis in the Wikimedia production cluster.
'''''' provided a live data stream of edits on Wikimedia wikis that anyone can tap and use to power editor tools and web apps, create beautiful visualisations, inform research, and extend MediaWiki.
RCStream subscribes to the [[mw:Manual:RCFeed|RCFeed]] from MediaWiki wikis. As a web developer, one can open the stream using JavaScript. As an app developer, one can use a suitable client library for your platform.
== API ==
RCStream provides a simple API for subscribing to [[mw:Manual:$wgRCFeeds|RCFeeds]] of MediaWiki wikis. After connecting you emit a <code>'subscribe'</code> event, specifying the wikis you wish to subscribe to. This use any of the below formats:
* a single hostname, such as <code></code>.
* an array of hostnames.
* hostnames matching a wildcard pattern such as <code>*</code> or <code>nl.*</code>.
* all wikis, by subscribing to the special topic name <code>*</code>.
You then receive <code>'change'</code> events whose data is an [[mw:RCFeed#Properties|RCFeed structure]] containing the type of change, the title of the page, the new revision number, etc.
The Socket.IO server uses the <code>/rc</code> namespace. It also implements an <code>/rcstream_status</code> endpoint that exposes internal state about connected clients and queue size that may help when debugging.
== Consumers ==
*[ Cocytus]. Tracks citations on Wikipedia.
*[ Meteor DDP]. Proxies change events combined with page content and diff from the API.
*[ Datasift]
*[ Demo on]. Example listener using JavaScript in the browser.
*Various researchers (per wiki-research-l, December 2014)
== Client example ==
{{Alert|content=As writing (January 2015), RCStream implements version 0.9 of the Socket.IO protocol, not 1.0 ([[phab:T68232]]). See also [ 0.9] and [ 0.9] on GitHub for more information.}}
=== JavaScript ===
<syntaxhighlight lang="javascript">
// Requires 0.9.x:
// browser code can load a minified Socket.IO JavaScript library;
// standalone code can install via 'npm install'.
var io = require( '' );
var socket = io.connect( '' );
socket.on( 'connect', function () {
    socket.emit( 'subscribe', '' );
} );
socket.on( 'change', function ( data ) {
    console.log( data.title );
} );
=== Python ===
Install dependencies:<syntaxhighlight lang="shell">
pip install socketIO_client==0.5.6
</syntaxhighlight>Get stream of events:<syntaxhighlight lang=python>
# -*- coding: utf-8 -*-
import socketIO_client
class WikiNamespace(socketIO_client.BaseNamespace):
    def on_change(self, change):
        print('%(user)s edited %(title)s' % change)
    def on_connect(self):
        self.emit('subscribe', '')
socketIO = socketIO_client.SocketIO('')
socketIO.define(WikiNamespace, '/rc')
== Wikimedia deployment ==
The [[mw:Manual:RCFeed|RCFeed]] of Wikimedia wikis is configured using [[mw:Manual:$wgRCFeeds|$wgRCFeeds]]. The JSON formatter is used with the Redis engine.
The RCStream servers are <code>rcs1001</code> and <code>rcs1001</code> (see also [ puppet node] and [ puppet role]). Each backend server runs multiple instances of RCStream, as well as a Redis instance that receives RCFeed messages from the [[Application servers|MediaWiki app servers]]. The servers exposes the RCStream backends through a local Nginx reverse proxy.
An [[LVS]] load balancer (<code>stream-lb</code>) is situated in front of the backend servers, exposed as [[]].
The RCStream server also responds at <code><nowiki></nowiki></code> with a simple text message; check this if you do not receive any events.
=== Beta Cluster ===
The [[Beta cluster]] has a simplified setup on a single VM instance running the rcstream Puppet role, exposed as [].
== See also ==
* [ Issue tracker (Phabricator workboard)]
* [[mw:Requests_for_comment/Publishing_the_RecentChanges_feed|MediaWiki RFC: RecentChanges feed]] - Original proposal that led to the creation of RCFeed logic in [[mw:|MediaWiki]] and the RCStream web service.
* [[]]: The older UDP-to-IRC service. Previously this was the only available logic in MediaWiki for exposing recent changes in real-time.
[[Category:Decommissioned services]]

Latest revision as of 17:45, 6 July 2018

Redirect to: