Aide:Extension:EventStreamConfig

This page is a translated version of the page Help:Extension:EventStreamConfig and the translation is 50% complete.
PD Note : si vous modifiez cette page, vous acceptez de placer votre contribution sous licence CC0. Plus d’informations sont disponibles sur le projet Aide dans le domaine public. PD

This EventStreamConfig extension provides library functions and an API endpoint for exporting event stream configuration from the $wgEventStreams MediaWiki configuration variable.

Cela permet la configuration centralisée des flux pour MediaWiki et les utilisations externes.

  • The EventLogging extension uses this with ResourceLoader to load configs for streams used on certain pages to dynamically configure client stream settings, like sample rate.
  • Mobile apps use the API endpoint to dynamically configure client stream settings like sample rate.
  • EventGate event intake service(s) use this to ensure that only events of a specific schema title are allowed into a stream.
  • EventBus and other server side event producers uses this to figure out which event intake service a given stream should be produced to.

Utilisation

Configuration de MediaWiki

$wgEventStreams is a list of individual stream configs. Each stream config must minimally specify its schema_title and its stream name settings. In $wgEventStreams, stream may either be a static stream name string, or a regex that matches stream names for which the stream config should be used.

Example:

$wgEventStreams = [
    'test.event' => [
        'stream' => 'test.event',
        'schema_title' => 'test/event',
        'sample_rate' => 0.15,
    ],
    'nonya' => [
        'stream' => 'nonya',
        'schema_title' => 'mediawiki/nonya',
        'sample_rate' => 0.5,
    ],
    'mediawiki.virtual_page_view' => [
        'stream' => 'mediawiki.virtual_page_view',
        'schema_title' => 'mediawiki/page/virtual-view',
        'sample_rate' => 0.1,
    ],
    '/^mediawiki.edit(\..+)?/' => [
        'stream' => '/^mediawiki.edit(\..+)?/',
        'schema_title' => 'mediawiki/edit',
        'sample_rate' => 0.8,
    ],
];

(Note: sample_rate is just an example setting)

Obtenir les configurations pour une liste de flux

StreamConfigs#get takes a list of stream names to return configs for. $wgEventStreams is keyed by stream name or stream regex pattern, and it is searched for stream names that match. The return value is a map from requested stream name to the matched stream config. By default any settings in StreamConfig::INTERNAL_SETTINGS are removed from the returned stream configs; as they are often not useful for client side configuration. The $includeAllSettings parameter disables this behavior.

Example:

$streamConfigs = MediaWikiServices::getInstance()->getService('EventStreamConfig.StreamConfigs');
$streamConfigs->get( ['test.event', 'mediawiki.edit.cohort1'] );

returns

[
   'test.event' => [
       'sample_rate' => 0.15,
   ],
   'mediawiki.edit.cohort1' => [
       'sample_rate' => 0.8,
   ]
]

streamconfigs MW API endpoint

curl http://wiki.domain.org/w/api.php?action=streamconfigs&format=json&streams=test.event|mediawiki.edit.cohort1
# returns
{
    "test.event" => {
        "sample_rate" => 0.15
    },
    "mediawiki.edit.cohort1": {
        "sample_rate" => 0.8
    }
}