Extension:EventBus
EventBus Release status: beta |
|
---|---|
Implementation | Data extraction |
Description | Propagation of change events to a RESTful service |
Author(s) | EEvans (WMF)talk |
Latest version | 0.5.0 |
Compatibility policy | Snapshots releases along with MediaWiki. Master is not backward compatible. |
MediaWiki | >= 1.42 |
Database changes | No |
License | GNU General Public License 2.0 or later |
Download | |
|
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Translate the EventBus extension if it is available at translatewiki.net | |
Issues | Open tasks · Report a bug |
The EventBus extension propagates state changes (edit, move, delete, revision visibility, etc) to an EventGate instance, providing consumers of the service with the means of tracking changes to MediaWiki content.
Install
- <translate> [[<tvar name=2>Special:ExtensionDistributor/EventBus</tvar>|Download]] and move the extracted <tvar name=name>
EventBus
</tvar> folder to your <tvar name=ext>extensions/
</tvar> directory.</translate>
<translate> Developers and code contributors should install the extension [[<tvar name=git>Special:MyLanguage/Download from Git</tvar>|from Git]] instead, using:</translate>cd extensions/
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventBus - <translate> Add the following code at the bottom of your <tvar name=1>LocalSettings.php </tvar> file:</translate>
wfLoadExtension( 'EventBus' );
- File:OOjs UI icon check-constructive.svg <translate> Done</translate> – <translate> Navigate to <tvar name=special>Special:Version</tvar> on your wiki to verify that the extension is successfully installed.</translate>
State events
Known issues
Ideally, this sort of change propagation would be atomic, that is to say, if one of the tracked changes is committed in MediaWiki, the corresponding event is guaranteed to be delivered (even if by eventual consistency). As this extension is hook-based, that is not currently the case; Truly reliable event delivery will likely require something bound to the corresponding database transaction. (tracked in <translate> task <tvar name=1>T120242</tvar></translate>.)
Configuration
Note: For this extension to be useful, you need to have Kafka installed with EventGate as the event-intake service.
To enable the sending of state events, add the following to your LocalSettings.php
, with the event service name and URLs set according to your environment.
$wgEventServices = [
'eventbus' => ['url' => 'http://hostname:8888/v1/events', 'timeout' => 10],
'eventgate' => ['url' => 'http://hostname:8192/v1/events'],
// ...
];
Purge events
MediaWiki core provides CDN purges to its EventRelayer, which is null by default. To enable sending CDN purges to EventGate/Kafka as well, use the EventBus adapter for EventRelayer as follows.
$wgEventRelayerConfig = [
'cdn-url-purges' => [
'class' => \MediaWiki\Extension\EventBus\Adapters\EventRelayer\CdnPurgeEventRelayer::class,
'stream' => 'resource-purge',
],
'default' => [
'class' => EventRelayerNull::class,
],
];
RunJob REST API
File:Under construction icon-blue.svg | <translate> This section is currently a draft.</translate> <translate> Material may not yet be complete, information may presently be omitted, and certain parts of the content may be subject to radical, rapid alteration.</translate> <translate> More information pertaining to this may be available on the [[<tvar|1>Extension talk:EventBus</>|talk page]].</translate> |
The RunJob REST API allows you to execute a job using a REST API endpoint.
Site configuration
To enable the RunJob REST API on your wiki, set $wgEventBusEnableRunJobAPI
in LocalSettings.php
. The RunJob REST API is compatible with MediaWiki 1.34 and later.
/**
* Enable the Run Job REST API
*
* @see https://www.mediawiki.org/wiki/Extension:EventBus#Run_Job_REST_API
*/
$wgEventBusEnableRunJobAPI = true;
Run job
Route: /eventbus/v0/internal/job/execute
Method: POST
Content-Type: application/json
Submits a job for execution by the event service.
This endpoint is released under v0/internal
; it should be considered unstable and may change in backwards incompatible ways without notice.
Request example
# Runs the job described in filename.json
curl -X POST -d @filename.json http:/examplewiki.org/w/rest.php/eventbus/v0/internal/job/execute --header "Content-Type:application/json"
Request parameters
Here are the minimum parameters required by the endpoint. The full schema of a job can be found in the mediawiki-event-schemas directory.
parameter | required | example | description |
---|---|---|---|
database
|
<translate> Required</translate> | enwiki
|
Name of the wiki database |
type
|
<translate> Required</translate> | deleteJob
|
Type of job |
params
|
<translate> Required</translate> | {
"namespace": 0,
"title": "testing",
"wikiPageId": 34,
"reason": "testing delete job",
"suppress": false,
"tags": [],
"logsubtype": "delete"
}
|
Parameters that are specific to the job |
mediawiki_signature
|
<translate> Required</translate> | d8c84b3d6c810c2db6bf1cb74400c25d4bc02d65
|
The cryptographic signature of the event based on the MediaWiki SecretKey |
Responses
200 | Success
| ||
---|---|---|---|
400 | Invalid event received
| ||
400 | Failed creating job from description
| ||
403 | Missing MediaWiki signature
| ||
403 | Invalid MediaWiki signature
| ||
415 | Unsupported Content-Type
| ||
423 | Wiki is in read-only mode
| ||
500 | Could not decode the event
| ||
500 | Internal Server Error
| ||
501 | Set $wgEventBusEnableRunJobAPI to true
|
Response schema
key | type | description |
---|---|---|
status
required |
boolean | Whether the job succeeded |
error
required |
string | A string of the error or empty if there was no error specified |
caught
required |
array | List of FQCNs (fully-qualified class names) corresponding to any exceptions caught |
timeMS
required |
float | Job execution time in milliseconds |
Known issues
In Windows environments this extension causes critical performance problems if registered endpoint is not available.
References
- T84923: Reliable publish / subscribe event bus
- T116786: Integrate eventbus-based event production into MediaWiki
- T120242: Reliable (atomic) MediaWiki event production
File:Wikimedia-logo black.svg | <translate> This {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extension|skin}} is being used on one or more [[<tvar name=2>m:Special:MyLanguage/Wikimedia projects</tvar>|Wikimedia projects]].</translate> <translate> This probably means that the {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extension|skin}} is stable and works well enough to be used by such high-traffic websites.</translate> <translate> Look for this {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extension's|skin's}} name in Wikimedia's <tvar name=2>CommonSettings.php</tvar> and <tvar name=3>InitialiseSettings.php</tvar> configuration files to see where it's installed.</translate> <translate> A full list of the {{<tvar name=1>#ifeq:Extension|Extension</tvar>|extensions|skins}} installed on a particular wiki can be seen on the wiki's <tvar name=ver>Special:Version</tvar> page.</translate> |
File:OOjs UI icon information-progressive.svg |
- Pages with script errors
- Pages with broken file links
- Beta status extensions
- Extensions without an image
- Data extraction extensions
- Extensions with release branches compatibility policy
- GPL licensed extensions
- Extensions in Wikimedia version control
- ArticleProtectComplete extensions
- ArticlePurge extensions
- ArticleRevisionVisibilitySet extensions
- BlockIpComplete extensions
- CentralNoticeCampaignChange extensions
- ChangeTagsAfterUpdateTags extensions
- LinksUpdateComplete extensions
- PageDelete extensions
- PageDeleteComplete extensions
- PageMoveComplete extensions
- PageSaveComplete extensions
- PageUndeleteComplete extensions
- RevisionRecordInserted extensions
- All extensions
- Drafts
- Analytics extensions
- Extensions used on Wikimedia