id int64 0 1.29M | original_id stringlengths 32 32 | swhid stringlengths 100 170 | sha1 stringlengths 40 40 | repo_name stringlengths 2 45 | repo_group stringclasses 12
values | filepath stringlengths 5 153 | name stringlengths 1 14.9k | type stringclasses 3
values | code stringlengths 7 2.12M |
|---|---|---|---|---|---|---|---|---|---|
18,000 | 8a59beece5bcb43c413f6f409df46294 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=149-159/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_safeParse | function | _safeParse(payload) {
try {
return JSON.parse(payload);
} catch (e) {
this._logger.log('error/parse', e);
this._hyper.post({
uri: new URI('/sys/queue/events'),
body: [ this._constructErrorMessage(e, payload) ]
});
}
... |
18,001 | d4dfac1f4efc37fdd8b6a03eabd44e94 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=375-396/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_test | function | /** Private methods */
_test(event) {
const logger = this._logger.child({
stream: event.meta.stream
});
try {
const optionIndex = this.rule.test(event);
if (optionIndex === -1) {
// no match, drop the message
logger.log('de... |
18,002 | b573a8ad0d8f0f98071c33ef270cdaf9 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=423-430/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_isBlacklisted | function | _isBlacklisted(event) {
if (this.disable_blacklist || !this.blacklist[event.meta.domain]) {
return false;
}
// We use `decodeURIComponent` on a full URI here as we would like
// to decode separator characters as well
return this.blacklist[event.meta.domain].test(decod... |
18,003 | 689003a850f4dba274f1207d266aac41 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=722-725/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::close | function | close() {
this._connected = false;
return this.consumer.disconnectAsync();
} |
18,004 | c90d3e7533bf75052896b1659518422b | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=582-584/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_errorStreamName | function | _errorStreamName() {
return `${ this._hyper.config.service_name }.error`;
} |
18,005 | 8033e6a32bfa0d1091306671f9ce275d | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=634-684/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_catch | function | _catch(message, retryMessage, e) {
const reportError = () => this._hyper.post({
uri: new URI('/sys/queue/events'),
body: [this._constructErrorMessage(e, message)]
});
if (e.constructor.name !== 'HTTPError') {
// We've got an error, but it's not from the updat... |
18,006 | 9fe3246c61e3e2ae666a9c97e422c585 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=610-632/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_isLimitExceeded | function | /**
* Checks whether retry limit for this rule is exceeded.
*
* @param {Object} message a retry message to check
* @param {Error} [e] optional Error that caused a retry
* @return {boolean}
* @private
*/
_isLimitExceeded(message, e) {
if (message.retries_left <= 0) {
... |
18,007 | 15e40622ec76b8c31ac1fa9c57d5e41d | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=64-131/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::constructor | function | /**
* Creates a new instance of a rule executor
*
* @param {Rule} rule
* @param {KafkaFactory} kafkaFactory
* @param {Object} hyper
* @param {Object} options
* @class
*/
constructor(rule, kafkaFactory, hyper, options) {
if (this.constructor.name === 'BaseExecutor') {
... |
18,008 | b7a1c4b706d0bdb430e60b8ada815ef0 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=133-147/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::subscribe | function | async subscribe() {
const prefix = this.options.test_mode ? `test-${ this._hyper.config.service_name }` : `${ this._hyper.config.service_name }`;
this.consumer = await this.kafkaFactory.createConsumer(
`${ prefix }-${ this.rule.name }`,
this.subscribeTopics,
this._hyp... |
18,009 | 068a1c293bbb03d2dd2340a8c1b25faf | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=398-421/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_sampleLog | function | _sampleLog(event, request, res) {
const sampleLog = () => {
const log = {
message: 'Processed event sample',
event_str: utils.stringify(event),
request: {
uri: `${ request.uri }`,
headers: request.headers,
... |
18,010 | accb0cbd664ed60329952e73db5975e7 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=586-608/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::_constructRetryMessage | function | _constructRetryMessage(event, errorRes, retriesLeft, retryEvent) {
const result = {
$schema: '/change-prop/retry/1.0.0',
meta: {
stream: this.retryStreamName(event.meta.stream),
uri: event.meta.uri,
domain: event.meta.domain
},
... |
18,011 | f53e2384fb92b2957f6332a2b5bbdf23 | swh:1:cnt:5e08e74ec2040f0b5386fc62d136c19c3a378485;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=578-580/ | ee9f6f63e305fa3a38b72d26b209835ba9718ecc | change-propagation | deployed | lib/base_executor.js | BaseExecutor::emitterId | function | emitterId() {
return `${ this._hyper.config.service_name }#${ this.rule.name }`;
} |
18,012 | fd9b049da1168746d2cc37f40a89c76c | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=27-87/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | GuaranteedProducer | type | class GuaranteedProducer extends kafka.Producer {
/**
* @inheritdoc
*/
constructor(conf, topicConf, logger) {
super(conf, topicConf);
this.on('delivery-report', (err, report) => {
const reporter = report.opaque;
if (err) {
return reporter.reject... |
18,013 | 3a640c4b48dc54212f79b7abf6f7bf10 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=89-114/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | AutopollingProducer | type | class AutopollingProducer extends kafka.Producer {
constructor(config, topicConfig, logger) {
super(config, topicConfig);
this.on('event.log', e => logger.log('debug/producer', e));
this.on('event.error', e => logger.log('error/producer', e));
}
/**
* @inheritdoc
*/
pr... |
18,014 | e5fa0a8e586a037d04144dc7e7247267 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=173-308/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory | type | class KafkaFactory {
/**
* Contains the kafka consumer/producer configuration. The configuration options
* are directly passed to librdkafka. For options see librdkafka docs:
* https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
*
* @param {Object} kafkaConf
* @param {O... |
18,015 | 4c1959fdb28236dd167eb2b3031a7776 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=116-171/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | MetadataWatch | type | class MetadataWatch extends EventEmitter {
constructor(consumer, consumeDC) {
super();
this._consumer = consumer;
this._knownTopics = [];
this._refreshInterval = undefined;
this._consumeDC = consumeDC;
}
_setup() {
return this.getTopics()
.then((topic... |
18,016 | d28122fd13b2255c0d819e62a7959a17 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=28-49/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | GuaranteedProducer::constructor | function | /**
* @inheritdoc
*/
constructor(conf, topicConf, logger) {
super(conf, topicConf);
this.on('delivery-report', (err, report) => {
const reporter = report.opaque;
if (err) {
return reporter.rejecter(err);
}
return reporter.res... |
18,017 | d0f5a03887d11b1a37e6bc96d23503a3 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=96-113/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | AutopollingProducer::produce | function | /**
* @inheritdoc
*/
produce(topic, partition, message, key) {
return new P((resolve, reject) => {
try {
const result = super.produce(topic, partition, message, key);
if (result !== true) {
return reject(result);
}
... |
18,018 | 5c11982a422ca84460644e74a6a3a89d | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=90-94/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | AutopollingProducer::constructor | function | constructor(config, topicConfig, logger) {
super(config, topicConfig);
this.on('event.log', e => logger.log('debug/producer', e));
this.on('event.error', e => logger.log('error/producer', e));
} |
18,019 | 2ea4a99300a0d9d88641803c157e0932 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=77-85/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | GuaranteedProducer::disconnect | function | /**
* @inheritdoc
*/
disconnect(cb) {
if (this._pollInterval) {
clearInterval(this._pollInterval);
}
return super.disconnect(cb);
} |
18,020 | 9fdc9201877463af5a836b9596ed58ec | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=51-75/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | GuaranteedProducer::produce | function | /**
* @inheritdoc
*/
produce(topic, partition, message, key) {
return new P((resolve, reject) => {
const report = {
resolver: resolve,
rejecter: reject
};
try {
const result = super.produce(topic, partition, messag... |
18,021 | ebcd79f109226d002d2976f1c9d76596 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=117-123/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | MetadataWatch::constructor | function | constructor(consumer, consumeDC) {
super();
this._consumer = consumer;
this._knownTopics = [];
this._refreshInterval = undefined;
this._consumeDC = consumeDC;
} |
18,022 | 55976bd6ff3c008f1944c9f544beff48 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=125-144/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | MetadataWatch::_setup | function | _setup() {
return this.getTopics()
.then((topics) => {
this._knownTopics = topics;
this._refreshInterval = setInterval(() => {
this.getTopics()
.then((refreshedTopics) => {
const topicsAdded = refreshedTopics
... |
18,023 | 22b916a2e03685cdf99b831e8f345449 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=146-163/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | MetadataWatch::getTopics | function | getTopics() {
/* eslint-disable-next-line security/detect-non-literal-regexp */
const dcRemoveRegex = new RegExp(`^${ this._consumeDC }\\.`);
return new P((resolve, reject) => {
this._consumer.getMetadata(undefined, (err, res) => {
if (err) {
retur... |
18,024 | 19aedf1000be504a2e653cbe40638c80 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=165-170/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | MetadataWatch::disconnect | function | disconnect() {
if (this._refreshInterval) {
clearInterval(this._refreshInterval);
}
return this._consumer.disconnect();
} |
18,025 | 796ffa56856b082825b87ba77a521c22 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=174-213/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::constructor | function | /**
* Contains the kafka consumer/producer configuration. The configuration options
* are directly passed to librdkafka. For options see librdkafka docs:
* https://github.com/edenhill/librdkafka/blob/master/CONFIGURATION.md
*
* @param {Object} kafkaConf
* @param {Object} kafkaConf.metadata... |
18,026 | c74341c1a464e97d4a9d6f054e11bf59 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=215-222/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::consumeDC | function | /**
* Returns a DC name to consume from
*
* @return {string}
*/
get consumeDC() {
return this._kafkaConf.dc_name || this._kafkaConf.consume_dc || 'datacenter1';
} |
18,027 | d8082c7a83b376ff268f86236ee489f7 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=224-231/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::produceDC | function | /**
* Returns a DC name to produce to
*
* @return {string}
*/
get produceDC() {
return this._kafkaConf.dc_name || this._kafkaConf.produce_dc || 'datacenter1';
} |
18,028 | a8cd963b31c26dd24c27d7d157df4178 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=233-264/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::createConsumer | function | /**
* Create new KafkaConsumer and connect it.
*
* @param {string} groupId Consumer group ID to use
* @param {Array} topics Topics to subscribe to
* @param {Object} [metrics] metrics reporter
* @param {Object} logger The logger instance to use
* @param {Object} consumerOverrides Consu... |
18,029 | 920dbc74ac7290336fae31c43ab26555 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=301-303/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::createProducer | function | createProducer(logger) {
return this._createProducerOfClass(AutopollingProducer, logger);
} |
18,030 | 024a6dea20587ff8cedc340a86603aa7 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=305-307/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::createGuaranteedProducer | function | createGuaranteedProducer(logger) {
return this._createProducerOfClass(GuaranteedProducer, logger);
} |
18,031 | 4d876e1a2758daf16ac828ab27e36bee | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=266-281/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::createMetadataWatch | function | createMetadataWatch(groupId) {
const conf = Object.assign({}, this._consumerConf);
conf['group.id'] = groupId;
conf['client.id'] = `${ Math.floor(Math.random() * 1000000) }`;
return new P((resolve, reject) => {
const consumer = new kafka.KafkaConsumer(conf, this._consumerTop... |
18,032 | aa78ca4ba8549c492502031d2a713581 | swh:1:cnt:e9891c87e2a0faa4b84033e2f53d304138b0cd30;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=283-299/ | fdbab6b3e7b91ba1ae5b919018a5b92030652799 | change-propagation | deployed | lib/kafka_factory.js | KafkaFactory::_createProducerOfClass | function | _createProducerOfClass(ProducerClass, logger) {
return new P((resolve, reject) => {
const producer = new ProducerClass(
this._producerConf,
this._producerTopicConf,
logger
);
producer.once('event.error', reject);
pro... |
18,033 | 0fae645a8def3cfd00897cd16df9fe1d | swh:1:cnt:89b2e4d9bd4759bbb6cf9c98ba93bc1cd6e9ea28;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=8-42/ | da42887a2146d4829567f4ab7162c79cc4a4c14e | change-propagation | deployed | lib/mixins.js | constructor | function | constructor(options) {
if (superclass !== Object) {
super(options);
} else {
// Don't need to pass the options to the Object super constructor.
super();
}
if (!options.redis) {
throw new Error('Redis options not provided to the rate_limite... |
18,034 | 68603a32bf7c03f6e11709101a0ff63d | swh:1:cnt:89b2e4d9bd4759bbb6cf9c98ba93bc1cd6e9ea28;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=50-53/ | da42887a2146d4829567f4ab7162c79cc4a4c14e | change-propagation | deployed | lib/mixins.js | MixinBuilder::with | function | with() {
return Array.prototype.slice.call(arguments)
.reduce((c, mixin) => mixin(c), this.superclass);
} |
18,035 | 0eeca063bfd814afbdbaaa8753979d6b | swh:1:cnt:89b2e4d9bd4759bbb6cf9c98ba93bc1cd6e9ea28;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=46-48/ | da42887a2146d4829567f4ab7162c79cc4a4c14e | change-propagation | deployed | lib/mixins.js | MixinBuilder::constructor | function | constructor(superclass) {
this.superclass = superclass;
} |
18,036 | 79049568907a0aad822a2f2e0d73bcfa | swh:1:cnt:89b2e4d9bd4759bbb6cf9c98ba93bc1cd6e9ea28;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=45-54/ | da42887a2146d4829567f4ab7162c79cc4a4c14e | change-propagation | deployed | lib/mixins.js | MixinBuilder | type | class MixinBuilder {
constructor(superclass) {
this.superclass = superclass;
}
with() {
return Array.prototype.slice.call(arguments)
.reduce((c, mixin) => mixin(c), this.superclass);
}
} |
18,037 | 3e70bbf7909bc7afcdb9fc71fe1cabe8 | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=8-86/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor | type | /**
* A rule executor managing matching and execution of a single rule
*/
class RetryExecutor extends BaseExecutor {
get subscribeTopics() {
return this.rule.topics.map(topic => `${ this.kafkaFactory.consumeDC }.${ this.retryStreamName(topic) }`);
}
statName(event) {
return this._hyper.me... |
18,038 | cce740b0ca694fc9efd720c0b2adf26c | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=12-14/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor::subscribeTopics | function | get subscribeTopics() {
return this.rule.topics.map(topic => `${ this.kafkaFactory.consumeDC }.${ this.retryStreamName(topic) }`);
} |
18,039 | 413c9a62e12c82fc8dc6d34988cba968 | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=21-33/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor::_delay | function | async _delay(message) {
const spec = this.rule.spec;
const absoluteDelay = spec.retry_delay *
Math.pow(spec.retry_factor, spec.retry_limit - message.retries_left);
if (!message.meta.dt || !Date.parse(message.meta.dt)) {
// No DT on the message, there's nothing we can do
... |
18,040 | ed2af547e05277d724f2d0aea6cb122a | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=57-79/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor::processMessage | function | async processMessage(message, handler) {
await this._delay(message);
try {
return await this._exec(
message.original_event, handler, new Date(message.meta.dt), message
);
} catch (err) {
const e = BaseExecutor.decodeError(err);
con... |
18,041 | 9e2356475aec5dcf39b1120156e3b8ba | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=35-55/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor::getHandler | function | getHandler(message) {
if (!message) {
// Don't retry if we can't parse an event, just log.
return undefined;
}
if (message.emitter_id !== this.emitterId()) {
// Not our business, don't care
return undefined;
}
if (this._isLimitExc... |
18,042 | 927d5375ef307b2113eed6756409eac9 | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=16-19/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor::statName | function | statName(event) {
return this._hyper.metrics.normalizeName(
`${ this.rule.name }-${ event.meta.stream.replace(/\./g, '_') }_retry`);
} |
18,043 | 5fb9a64f2b32488a2ae0060c3c95c042 | swh:1:cnt:4ba1516bd114a6b0fa768ffd624c6b9529e6ef13;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=81-84/ | f656260e91379da0c01967c1b8279867a20d4472 | change-propagation | deployed | lib/retry_executor.js | RetryExecutor::_dedupeMessage | function | // Don't deduplicate retries
_dedupeMessage(expander) {
return P.resolve(false);
} |
18,044 | 953c32fe3e7afecf0a0cb0eb473c1458 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=44-81/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | _compileErrorCheckCondition | function | /**
* Creates a JS function that verifies property equality
*
* @param {Object} retryDefinition the condition in the format of 'retry_on' stanza
* @return {Function} a function that verifies the condition
*/
function _compileErrorCheckCondition(retryDefinition) {
function createCondition(retryCond, option) {
... |
18,045 | 818a2772a5a3ef680ba1cb11c2d82f03 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=118-160/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | _compileMatch | function | function _compileMatch(obj, result, name, fieldName) {
function _compileArrayMatch(objToSearch, nameToSearch) {
const itemsCheck = objToSearch.map((item, index) => `${ nameToSearch }.find((item) => ${ _compileMatch(item, {}, 'item', index) })`).join(' && ');
return `Array.isArray(${ nameToSearch })$... |
18,046 | e5fe6c309d9d68c877b90587a5f15605 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=83-88/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | _getMatchObjCode | function | function _getMatchObjCode(obj) {
if (obj.constructor === Object) {
return `{${ Object.keys(obj).map((key) => `${ key }: ${ _getMatchObjCode(obj[key]) }`).join(', ') }}`;
}
return obj;
} |
18,047 | 61e6e9e6190627f9876fdaf7a45107e0 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=51-64/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | _compileErrorCheckCondition::createCondition | function | function createCondition(retryCond, option) {
if (retryCond === 'status') {
const opt = option.toString();
if (/^[0-9]+$/.test(opt)) {
return `(res["${ retryCond }"] === ${ opt })`;
}
if (/^[0-9x]+$/.test(opt)) {
return `/^${ opt.re... |
18,048 | b7d0a9617462b6f5a2478265fb315376 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=90-116/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | _compileNamedRegex | function | function _compileNamedRegex(obj, result, name, fieldName) {
const captureNames = [];
const normalRegex = obj.replace(/\(\?<(\w+)>/g, (_, matchedName) => {
captureNames.push(matchedName);
return '(';
});
/* eslint-disable-next-line security/detect-non-literal-regexp */
const numGroups... |
18,049 | c1e059f20bfbf02624cd6f024727413e | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=119-122/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | _compileMatch::_compileArrayMatch | function | function _compileArrayMatch(objToSearch, nameToSearch) {
const itemsCheck = objToSearch.map((item, index) => `${ nameToSearch }.find((item) => ${ _compileMatch(item, {}, 'item', index) })`).join(' && ');
return `Array.isArray(${ nameToSearch })${ itemsCheck.length ? (` && ${ itemsCheck }`) : '' }`;
... |
18,050 | df81fc03c12cb4dd42520dfaf60cc135 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=163-235/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::constructor | function | constructor(name, spec) {
this.name = name;
this.spec = spec || {};
const topics = this.spec.topics || (this.spec.topic && [ this.spec.topic ]);
if (!topics || !Array.isArray(topics) || !topics.length) {
throw new Error(`No topics specified for rule ${ this.name }`);
... |
18,051 | 5056ff697da3f0387070c5400941ae0a | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=237-240/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::isBasicRule | function | static isBasicRule(ruleSpec) {
const topics = ruleSpec.topics || [ ruleSpec.topic ];
return !topics.some(topic => /^\/.+\/$/.test(topic));
} |
18,052 | 69af8538193a56465de5321da301a1bd | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=242-246/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::newWithTopicNames | function | static newWithTopicNames(ruleName, ruleSpec, topicNames) {
const newSpec = Object.assign({}, ruleSpec);
newSpec.topics = topicNames;
return new Rule(ruleName, newSpec);
} |
18,053 | c1d93bd742192d6a7d71a9d8343e46b1 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=248-266/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::shouldAbandon | function | /**
* Whether the claim_ttl or root_claim_ttl has passed and the event should be abandoned
*
* @param {Object} message the event to check
* @return {boolean} whether to abandon the event or not
*/
shouldAbandon(message) {
const now = Date.now();
if (this.spec.claim_ttl &&
... |
18,054 | 4e980e48f706cba1b69a1d269f300ea9 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=268-279/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::_processMatchNot | function | _processMatchNot(matchNot) {
if (!matchNot) {
return (() => false);
}
if (Array.isArray(matchNot)) {
const tests = matchNot.
map((match) => (this._processMatch(match)).test).
filter(func => !!func);
return message => tests.some(... |
18,055 | 64469620959ca074ff012fbcdaa567ea | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=328-349/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::_processMatch | function | _processMatch(match) {
if (!match) {
// No particular match specified, so we
// should accept all events for this topic
return;
}
const obj = {};
const test = _compileMatch(match, obj, 'message');
try {
return {
/* ... |
18,056 | 9fd49fea63524bad08bdbbc4690cf513 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=309-322/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::getLimiterKey | function | /**
* Returns the key to use for a rate-limiter of the certain type
*
* @param {string} type limiter type
* @param {Object} expander the expander containing the message and match
* @return {string|null}
*/
getLimiterKey(type, expander) {
const keyTemplate = this._limiterKeyTemp... |
18,057 | 1862b79709e53c1c078754767a04758d | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=293-307/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::getHandler | function | /**
* Returns a rule handler that contains of a set of exec template
* and expander function
*
* @param {Integer} index an index of the switch option
* @return {Object}
*/
getHandler(index) {
const option = this._options[index];
return {
exec: option.exec,
... |
18,058 | d32fddee71c079686bd2c1e0c924d6b2 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=281-291/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::test | function | /**
* Tests the message against the compiled evaluation test. In case the rule contains
* multiple options, the first one that's matched is choosen.
*
* @param {Object} message the message to test
* @return {Integer} index of the matched option or -1 of nothing matched
*/
test(message)... |
18,059 | a6384d4094a2788289d6de1ac83d6f62 | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=324-326/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::getRateLimiterTypes | function | getRateLimiterTypes() {
return Object.keys(this._limiterKeyTemplates);
} |
18,060 | 78cd872cd880d172fc819f45afcc4f0f | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=351-381/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule::_processExec | function | _processExec(exec) {
if (!exec) {
// nothing to do, the rule is a no-op
this.noop = true;
return;
}
if (!Array.isArray(exec)) {
exec = [exec];
}
const templates = [];
for (let idx = 0; idx < exec.length; idx++) {
... |
18,061 | b3cdf744194c425a699d0e87e298b1ee | swh:1:cnt:6ae679aeee183b2dfe0136e9857320dd54695e62;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=162-382/ | 50e710f97923f02bfbfdfb6f98ef6349671b4b93 | change-propagation | deployed | lib/rule.js | Rule | type | class Rule {
constructor(name, spec) {
this.name = name;
this.spec = spec || {};
const topics = this.spec.topics || (this.spec.topic && [ this.spec.topic ]);
if (!topics || !Array.isArray(topics) || !topics.length) {
throw new Error(`No topics specified for rule ${ this.... |
18,062 | 36dbdc89810ef86b7e6469d6481b5080 | swh:1:cnt:e436d1619ae52ecd9107c8116185d32dd8e74046;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=6-61/ | 57ef9b796ed47712cdb5c8bfeac45bde1621ed1b | change-propagation | deployed | lib/rule_executor.js | RuleExecutor | type | /**
* A rule executor managing matching and execution of a single rule
*/
class RuleExecutor extends BaseExecutor {
get subscribeTopics() {
return this.rule.topics.map(topic => `${ this.kafkaFactory.consumeDC }.${ topic }`);
}
statName(event) {
return this._hyper.metrics.normalizeName(
... |
18,063 | a9c2a1837ac216d1ada4ffbe5aa357e1 | swh:1:cnt:e436d1619ae52ecd9107c8116185d32dd8e74046;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=10-12/ | 57ef9b796ed47712cdb5c8bfeac45bde1621ed1b | change-propagation | deployed | lib/rule_executor.js | RuleExecutor::subscribeTopics | function | get subscribeTopics() {
return this.rule.topics.map(topic => `${ this.kafkaFactory.consumeDC }.${ topic }`);
} |
18,064 | 0170ee694fb135f400144f2dadcbe8da | swh:1:cnt:e436d1619ae52ecd9107c8116185d32dd8e74046;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=47-60/ | 57ef9b796ed47712cdb5c8bfeac45bde1621ed1b | change-propagation | deployed | lib/rule_executor.js | RuleExecutor::_dedupeMessage | function | _dedupeMessage(expander) {
let dedupeKey;
if (this.rule.topics.length === 1) {
dedupeKey = this.rule.name;
} else {
dedupeKey = `${ this.rule.name }-${ expander.message.meta.stream }`;
}
return this._hyper.post({
uri: new URI(`/sys/dedupe/${ de... |
18,065 | e8e65f8e3a1879e8d44b97f0e968bf68 | swh:1:cnt:e436d1619ae52ecd9107c8116185d32dd8e74046;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=37-45/ | 57ef9b796ed47712cdb5c8bfeac45bde1621ed1b | change-propagation | deployed | lib/rule_executor.js | RuleExecutor::processMessage | function | async processMessage(message, handler) {
try {
return await this._exec(message, handler);
} catch (err) {
const e = BaseExecutor.decodeError(err);
const retryMessage = this._constructRetryMessage(message, e);
return this._catch(message, retryMessage, e);
... |
18,066 | 0e2da5533e5f1291735d3d72f27bf5bd | swh:1:cnt:e436d1619ae52ecd9107c8116185d32dd8e74046;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=14-17/ | 57ef9b796ed47712cdb5c8bfeac45bde1621ed1b | change-propagation | deployed | lib/rule_executor.js | RuleExecutor::statName | function | statName(event) {
return this._hyper.metrics.normalizeName(
`${ this.rule.name }-${ event.meta.stream.replace(/\./g, '_') }`);
} |
18,067 | cd8ce9570fca9e9c4a5b4acd4a4b635e | swh:1:cnt:e436d1619ae52ecd9107c8116185d32dd8e74046;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=19-35/ | 57ef9b796ed47712cdb5c8bfeac45bde1621ed1b | change-propagation | deployed | lib/rule_executor.js | RuleExecutor::getHandler | function | /**
* Returns a handler to be used or undefined.
*
* @param {Object} message the message to process
* @return {Function|boolean}
*/
getHandler(message) {
if (!message) {
// no message we are done here
return undefined;
}
const handlerIndex = t... |
18,068 | 5e2f3c6ba46303b166f5228c7c1cc90b | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=10-45/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | BasicSubscription | type | class BasicSubscription {
constructor(options, kafkaFactory, hyper, ruleName, ruleSpec) {
this._kafkaFactory = kafkaFactory;
this._options = options;
this._hyper = hyper;
ruleSpec.sample = ruleSpec.sample || options.sample;
this._rule = new Rule(ruleName, ruleSpec);
... |
18,069 | 13b2803cc45313fd2b0374c09967a897 | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=46-144/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | RegexTopicSubscription | type | // TODO: rewrite this one
class RegexTopicSubscription {
constructor(options, kafkaFactory, hyper, ruleName, ruleSpec, metadataWatch) {
this._kafkaFactory = kafkaFactory;
this._options = options;
this._hyper = hyper;
this._ruleName = ruleName;
this._ruleSpec = ruleSpec;
... |
18,070 | e5cfff1cc10daa821e5cf16202a6ed6a | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=146-191/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | Subscriber | type | class Subscriber {
constructor(options, kafkaFactory) {
this._kafkaFactory = kafkaFactory;
this._options = options;
this._subscriptions = [];
this._metadataWatch = undefined;
}
async _createSubscription(hyper, ruleName, ruleSpec) {
if (Rule.isBasicRule(ruleSpec)) {
... |
18,071 | 8aa661b7cac0e44578e5e1b1268b7d30 | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=11-22/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | BasicSubscription::constructor | function | constructor(options, kafkaFactory, hyper, ruleName, ruleSpec) {
this._kafkaFactory = kafkaFactory;
this._options = options;
this._hyper = hyper;
ruleSpec.sample = ruleSpec.sample || options.sample;
this._rule = new Rule(ruleName, ruleSpec);
this._subscribed = false;
... |
18,072 | b5ddc7883194681bcef147ebd2423caf | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=24-37/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | BasicSubscription::subscribe | function | async subscribe() {
if (this._subscribed) {
throw new Error('Already subscribed!');
}
this._hyper.logger.log('info/subscription', {
message: 'Subscribing based on basic topics',
rule: this._rule.name,
topics: this._rule.topics
});
... |
18,073 | 47d7eea31192fd62f6efd06292240c3b | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=39-44/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | BasicSubscription::unsubscribe | function | unsubscribe() {
if (this._subscribed) {
this._executor.close();
this._retryExecutor.close();
}
} |
18,074 | cfb20e8c7edc10570d2d72e94f151dd2 | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=93-108/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | RegexTopicSubscription::_filterTopics | function | /**
* Filters out which topic names are ok to subscribe to.
*
* @param {Array} proposedTopicNames a set of available topic names
* to check which to subscribe to
* @return {Array}
* @private
*/
_filterTopics(proposedTopicNames) {
return proposedTopicNames.fi... |
18,075 | 7ae6496c0d510b229a2facbd3e9464d9 | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=48-91/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | RegexTopicSubscription::constructor | function | constructor(options, kafkaFactory, hyper, ruleName, ruleSpec, metadataWatch) {
this._kafkaFactory = kafkaFactory;
this._options = options;
this._hyper = hyper;
this._ruleName = ruleName;
this._ruleSpec = ruleSpec;
ruleSpec.sample = ruleSpec.sample || options.sample;
... |
18,076 | 7a6ec432dfa8a9503d3e11a590a8be8e | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=110-131/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | RegexTopicSubscription::_subscribeTopics | function | async _subscribeTopics(topicNames) {
this._filteredTopics = topicNames;
const topicRule = Rule.newWithTopicNames(this._ruleName,
this._ruleSpec, this._filteredTopics);
this._hyper.logger.log('info/subscription', {
message: 'Subscribing based on regex',
rule: ... |
18,077 | c88bebe68a1d908871c15ab4a88a2042 | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=133-136/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | RegexTopicSubscription::subscribe | function | async subscribe() {
const topics = await this._metadataWatch.getTopics();
await this._subscribeTopics(this._filterTopics(topics));
} |
18,078 | b6c4540a98aa3d8760e219087fed59be | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=138-143/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | RegexTopicSubscription::unsubscribe | function | async unsubscribe() {
if (this._subscribed) {
this._subscribed = false;
await Promise.all(this._executors.map(executor => executor.close()));
}
} |
18,079 | 6262a5faa7cdeb7f85c4a0225ed2ea1b | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=147-153/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | Subscriber::constructor | function | constructor(options, kafkaFactory) {
this._kafkaFactory = kafkaFactory;
this._options = options;
this._subscriptions = [];
this._metadataWatch = undefined;
} |
18,080 | 5551bb58637054ff87a2734f66e701a4 | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=155-169/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | Subscriber::_createSubscription | function | async _createSubscription(hyper, ruleName, ruleSpec) {
if (Rule.isBasicRule(ruleSpec)) {
return new BasicSubscription(this._options,
this._kafkaFactory, hyper, ruleName, ruleSpec);
}
if (!this._metadataWatch) {
this._metadataWatch = await this._kafkaFacto... |
18,081 | 32d7032a80b6016b6b7aab5d71c2027c | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=185-190/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | Subscriber::unsubscribeAll | function | unsubscribeAll() {
this._subscriptions.forEach(subscription => subscription.unsubscribe());
if (this._metadataWatch) {
this._metadataWatch.disconnect();
}
} |
18,082 | 4f27e9829ec69f25fe929a90712ae33a | swh:1:cnt:7c30f93c46b519609123abb3364332a0cef8c0aa;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=171-183/ | 80e669df79a53f2ccd30519071bf400fd5fcf720 | change-propagation | deployed | lib/rule_subscriber.js | Subscriber::subscribe | function | /**
* Subscribe a rule spec under a certain rule name
*
* @param {HyperSwitch} hyper the request dispatcher
* @param {string} ruleName the name of the rule
* @param {Object} ruleSpec the rule specification
* @return {Promise}
*/
async subscribe(hyper, ruleName, ruleSpec) {
... |
18,083 | e57d5ff79a8d741a2c5acdd3d43ce429 | swh:1:cnt:0ab7af43052fc150fd4dab13bb61315abbaea29e;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=8-47/ | 41bfcb94eb454884c3a740d8ba5efdf31b45c619 | change-propagation | deployed | lib/sampler.js | Sampler | type | class Sampler {
constructor(options) {
this._options = options || {};
if (!this._options.hash_template) {
throw new Error('Sampling requires that a hash_template be configured');
}
if (!this._options.rate) {
throw new Error('Sampling requires that a rate be c... |
18,084 | 418edc8c4359b26c694e91d34eb274ec | swh:1:cnt:0ab7af43052fc150fd4dab13bb61315abbaea29e;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=9-24/ | 41bfcb94eb454884c3a740d8ba5efdf31b45c619 | change-propagation | deployed | lib/sampler.js | Sampler::constructor | function | constructor(options) {
this._options = options || {};
if (!this._options.hash_template) {
throw new Error('Sampling requires that a hash_template be configured');
}
if (!this._options.rate) {
throw new Error('Sampling requires that a rate be configured');
... |
18,085 | 7d80c15367a63f42d2dff95c968bda48 | swh:1:cnt:0ab7af43052fc150fd4dab13bb61315abbaea29e;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=38-46/ | 41bfcb94eb454884c3a740d8ba5efdf31b45c619 | change-propagation | deployed | lib/sampler.js | Sampler::hash | function | /**
* Returns a numeric representation of the value's murmur32 hash.
*
* @param {string} value
* @return {number}
*/
static hash(value) {
return murmur(value);
} |
18,086 | eae0638aa979a15bddb0ede364b1e34d | swh:1:cnt:0ab7af43052fc150fd4dab13bb61315abbaea29e;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=26-36/ | 41bfcb94eb454884c3a740d8ba5efdf31b45c619 | change-propagation | deployed | lib/sampler.js | Sampler::accept | function | /**
* Returns true if this request should be sampled, false if it should
* be ignored.
*
* @param {Object} context
* @return {boolean}
*/
accept(context) {
const hashSource = this._hashSourceTemplate.expand(context);
return (Sampler.hash(hashSource) <= this._maxHash);
... |
18,087 | e9b120310a513ebb0b0ce2814facdfad | swh:1:cnt:101d98a0d609d03d76e32a0c8229deac3ea61d03;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=9-133/ | 9cb833d31caa40004ee2aae1574eb30a7f6e9779 | change-propagation | deployed | sys/deduplicator.js | Deduplicator | type | class Deduplicator extends mixins.mix(Object).with(mixins.Redis) {
constructor(options) {
super(options);
this._options = options || {};
this._expire_timeout = options.window || 86400;
this._prefix = this._options.redis_prefix || 'CP';
}
/**
* Checks whether the messag... |
18,088 | b6a8cc9773464bfe76568a2608f11f3b | swh:1:cnt:101d98a0d609d03d76e32a0c8229deac3ea61d03;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=10-16/ | 9cb833d31caa40004ee2aae1574eb30a7f6e9779 | change-propagation | deployed | sys/deduplicator.js | Deduplicator::constructor | function | constructor(options) {
super(options);
this._options = options || {};
this._expire_timeout = options.window || 86400;
this._prefix = this._options.redis_prefix || 'CP';
} |
18,089 | 43bfe41fc6d0aad1526fee702be38bb9 | swh:1:cnt:101d98a0d609d03d76e32a0c8229deac3ea61d03;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=18-132/ | 9cb833d31caa40004ee2aae1574eb30a7f6e9779 | change-propagation | deployed | sys/deduplicator.js | Deduplicator::checkDuplicate | function | /**
* Checks whether the message is a duplicate
*
* @param {HyperSwitch} hyper
* @param {Object} req
* @return {Promise} response status shows whether it's a duplicate or not.
*/
checkDuplicate(hyper, req) {
const name = req.params.name;
const message = req.body;
... |
18,090 | dcf26b2fe96bb02345731f67d0688186 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=9-28/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | createBackLinksTemplate | function | function createBackLinksTemplate(options) {
return {
template: new Template(extend(true, {}, options.templates.mw_api, {
method: 'post',
body: {
format: 'json',
action: 'query',
list: 'backlinks',
bltitle: '{{request.par... |
18,091 | 54e14d77ce25a7326a3df8e9dbb927e7 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=30-49/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | createImageUsageTemplate | function | function createImageUsageTemplate(options) {
return {
template: new Template(extend(true, {}, options.templates.mw_api, {
method: 'post',
body: {
format: 'json',
action: 'query',
list: 'imageusage',
iutitle: '{{request.p... |
18,092 | fc729493f6cbaf05b5373fc6435249c9 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=116-137/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | _sendContinueEvent | function | function _sendContinueEvent(hyper, stream, origEvent, continueToken) {
return hyper.post({
uri: '/sys/queue/events',
body: [{
$schema: '/change-prop/continue/1.0.0',
meta: {
stream,
uri: origEvent.meta.uri,
request_id: origEvent... |
18,093 | 17196ad4437146f2eb3c1c8561de936b | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=74-114/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | createWikidataTemplate | function | function createWikidataTemplate(options) {
return {
template: new Template(extend(true, {}, options.templates.mw_api, {
method: 'post',
body: {
format: 'json',
action: 'wbgetentities',
ids: '{{message.page_title}}',
prop... |
18,094 | 5761178c0589b6caeada163e14775c0a | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=51-72/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | createTranscludeInTemplate | function | function createTranscludeInTemplate(options) {
return {
template: new Template(extend(true, {}, options.templates.mw_api, {
method: 'post',
body: {
format: 'json',
action: 'query',
prop: 'transcludedin',
tiprop: 'title',... |
18,095 | 42bf0cad055db1aa71f3d49cdbc1c657 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=139-164/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | _sendResourceChanges | function | function _sendResourceChanges(hyper, items, originalEvent, tags, streamName) {
return hyper.post({
uri: '/sys/queue/events',
body: items.map((item) => {
// TODO: need to check whether a wiki is http or https!
const resourceURI =
`https://${ item.domain }/wiki/... |
18,096 | 2f3c6e37123c9ba8434a17c304408b4f | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=167-184/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor::constructor | function | constructor(options) {
this.options = options;
this.siteInfoCache = {};
this.backLinksRequest = createBackLinksTemplate(options);
this.imageLinksRequest = createImageUsageTemplate(options);
this.transcludeInRequest = createTranscludeInTemplate(options);
this.wikidataReque... |
18,097 | 5e800aa1218f7729dd78b2a27e74a907 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=186-195/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor::processBackLinks | function | processBackLinks(hyper, req) {
const context = {
request: req,
message: req.body
};
const originalEvent = req.body.original_event || req.body;
return this._getSiteInfo(hyper, req.body)
.then((siteInfo) => this._fetchAndProcessBatch(hyper, this.backLinksReq... |
18,098 | 53ac2610adcd69fb2eb1d4e71a0a25b5 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=197-214/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor::processTranscludes | function | processTranscludes(hyper, req) {
const message = req.body;
const context = {
request: req,
message
};
const originalEvent = req.body.original_event || req.body;
return this._getSiteInfo(hyper, message)
.then((siteInfo) => {
const title ... |
18,099 | 360fd7424949ae7fb3e23b4ac0e51626 | swh:1:cnt:10e4392c14fd08b25c6de4b00a1a0a74c367e773;origin=https://gerrit.wikimedia.org/r/mediawiki/services/change-propagation.git;lines=216-239/ | 0a315bd5e53af3bee7d5a6bae593e6e1c0c8db0c | change-propagation | deployed | sys/dep_updates.js | DependencyProcessor::processWikidata | function | processWikidata(hyper, req) {
const context = {
request: req,
message: req.body
};
return hyper.request(this.wikidataRequest.template.expand(context))
.then((res) => {
if (this.wikidataRequest.shouldProcess(res)) {
const items = this.wi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.