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 |
|---|---|---|---|---|---|---|---|---|---|
900 | f3c0fda840ff0bbe73771cc656f35d5a | swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=13-46/ | c7c2c862631abb5881380e836f568ce1f0adbc9f | kafkasse | analytics | lib/error.js | ExtendableError::constructor | function | /**
* @param {string|Error} e
* @constructor
*/
constructor(e) {
// Allow errors to be instantied by wrapping other errors.
if (e instanceof Error) {
// message is an Error, instantiate this with the message string.
super(e.message);
// Copy each of... |
901 | 4d629e10cafa65ae4eb008fe6a26c925 | swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=81-102/ | c7c2c862631abb5881380e836f568ce1f0adbc9f | kafkasse | analytics | lib/error.js | KafkaSSEError::toJSON | function | /**
* Returns a JSON.stringify-able object.
* This will include properties defined by
* ExtendableError and KafkaSSEError, as well
* as any extra enumerable properties that have been set.
*
* @return {Object}
*/
toJSON() {
let obj = {};
// Include these non enumera... |
902 | 8d4afa341df5f58c288cc01750f36b7f | swh:1:cnt:fefb130ce530968670afc73f1ec607206097c2c5;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=55-79/ | c7c2c862631abb5881380e836f568ce1f0adbc9f | kafkasse | analytics | lib/error.js | KafkaSSEError::constructor | function | /**
* Creates a new KafkaSSEError with extraPropeties
* defined.
*
* @param {string|Error} e
* @param {Object extraProperties}
* @constructor
*/
constructor(e, extraProperties) {
super(e);
Object.defineProperty(this, 'origin', {
value: 'KafkaS... |
903 | 8f4eb4270dde3726592d5aa802c6346a | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=20-992/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE | type | /**
* Represents a Kafka Consumer -> Server Side Events connection.
*
* This creates a new Kafka Consumer and passes consumed
* messages to the connected SSE client.
*
* Usage:
*
* let kafkaSse = new KafkaSSE(req, res, options);
* kafkaSse.connect(['topicA']);
*/
class KafkaSSE {
/**
* @param {htt... |
904 | 126bac9cf5d11a11bdf06107a4d4abd9 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=33-310/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::constructor | function | /**
* @param {http.ClientRequest} req
*
* @param {http.ServerResponse} res
*
* @param {Object} options
*
* @param {Object} options.kafkaConfig: suitable for passing to
* rdkafka.KafkaConsumer constructor. group.id and
* enable.auto.c... |
905 | e5f2bc3e7508077e1c4fe90c1500c1a9 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=313-405/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::connect | function | /**
* Parses assignments, then connects the KafkaConsumer and assigns it.
* Once that works, the initialization stage is over, and the SSE client
* is created and the consume loop starts. Up until _start is called,
* it is possible to end the request with a sensable HTTP error response.
* Once... |
906 | cf4ea92ebbd7d8f64dfbe97b4bf0db45 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=408-567/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_init | function | /**
* Creates the Kafka Consumer and assigns it to start consuming at assignments.
*
* @param {Object|Array} assignments either an array of topic names, a string of comma
* delimited topic names, or an array of objects containing
* topic, partition, and offset suit... |
907 | 70c8fff2070544f6ee9a115210d752db | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=593-624/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_start | function | _start() {
// Start the consume -> sse send loop.
this.log.info('Initializing KafkaSSE connection and starting consume loop.');
const responseHeaders = {};
let disableSSEFormatting = false;
// If user wants application/json, then disableSSEFormatting.
// Else just use t... |
908 | 7536538cdfdb1f8976bf9100b09a38b5 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=570-590/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_checkTopicsAvailable | function | /**
* Throws TopicNotAvailableError if any topic in topics Array is not
* in the list of available topics.
*
* @param {Array} topics
* @throws TopicNotAvailableError if any of the topics are not available.
*/
_checkTopicsAvailable(topics) {
// Find any invalid/unavailable topic... |
909 | c6be298cf5f6610b39ea3decb60d8d49 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=627-677/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_loop | function | /**
* Consume, send a message, and then consume again.
* This will loop forever, until disconnect or error.
*/
_loop(startTime) {
startTime = startTime || Date.now();
// Consume, send the message, and then consume again
// This will loop forever, until disconnect or error.
... |
910 | 6d1232edc2f5bb2ca0d74e4769e17ee9 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=680-710/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_updateLatestOffsetsMap | function | /**
* Given a kafkaMessage consumed from node-rdkafka KafkaConsumer,
* This will update the this.latestOffsetsMap with the kafkaMessage's
* topic, partition, and offset|timestamp + 1.
*
* NOTE: + 1 is necessary for Last-Event-ID for EventSource auto-resuming on reconnect.
* Without the + 1... |
911 | 81de61c14a85bd4ae1d8d822ce280b26 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=713-782/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_consume | function | /**
* Consumes messages from Kafka until we find one that parses and matches
* via the matcher function, and then returns a promise that includes
* the matched and deserialized message.
*
* @return {Promise<Object>}
*/
_consume() {
// If we have finished (by calling this.discon... |
912 | d31e10f33b811b06a0fe40275e51ba80 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=785-811/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_deserialize | function | /**
* Returns a Promise of an Object deserialized from kafkaMessage.
* This calls the this.deserializer function configured using
* options.deserializer in the constructor.
* If this.deserializer throws any error, the error will be
* wrapped as a DeserializationError and thrown up to the caller... |
913 | de9c5c6bfb3f68ae8a7aeb7ee741e9e9 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=813-851/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_filter | function | /**
* Returns a Promise of a deserialized kafkaMessage,
* or false if this kafkaMessage should be skipped.
* This calls the this.filterer function configured using
* options.filterer in the constructor.
* If this.filterer throws any error, the error will be
* wrapped as a FilterError and t... |
914 | 2810355e1c536abd9c64682e9c253cb4 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=853-874/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_error | function | /**
* Logs error, and returns error with deleted stack, suitable for
* returning to clients.
*
* @param {Error} e
* @param {string} level log level to use
* @return {Object} serialized error without stack.
*/
_error(e, level) {
level = level || 'error';
level = ... |
915 | 001c53acef43502751740201bc99f3a8 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=876-889/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::_resFinished | function | /**
* Checks if the HTTP response is finished.
* Returns true if if this.res is undefined, or if the this.res.finished,
* or if res.connection.destroyed.
*
* @return {boolean}
*/
_resFinished() {
const res = this.res;
if (!res || res.finished || (res.connection && res.c... |
916 | 8bcf9ba70ea93e43549d3207830bac05 | swh:1:cnt:671284804fb1d15a7fad1bd7d6823f2d5d300263;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=892-991/ | 093d3fba075e9f2a3cb74c3207c1bafa32bd34f8 | kafkasse | analytics | lib/KafkaSSE.js | KafkaSSE::disconnect | function | /**
* Disconnects the KafkaConsumer and closes the sse client and/or http response.
* If disconnect() has already been called, this does nothing.
*
* @param {string} reason Reason disconnect was called, used for logging.
* @return {Promise} Resolved if disconnect was successful, rejected if err... |
917 | 4dc1ff5bdab88d8860d05ebec90eee82 | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=5-241/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse | type | /**
* Wraps an HTTP response to ease sending SSE formatted events
* via text/event-stream and chunked transfer encoding.
*
* Usage:
* sse = new SSEResponse(req, res);
* sse.start();
* sse.send('message', {'my': 'first message'}, 1001);
* sse.send('message', {'my': 'second message'}, 1002);
* // or with a... |
918 | 0764d71302f37f19066509aa87077598 | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=21-56/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::constructor | function | /**
* @param {http.ServerResponse} res
* @param {Object} options
* @param {Object} options.headers: Extra headers to add to the SSE response.
* The defaults are: {
* 'Content-Type': 'text/event-stream',
* 'Cache-Control': 'no-cache',
* ... |
919 | ae34a7aea75992e562249f4f18d89f3c | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=59-70/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::start | function | /**
* Starts sending the SSE response body.
*/
start() {
this.res.writeHead(200, this.headers);
if (this.disableSSEFormatting) {
return this._write('\n');
} else {
return this._write(':ok\n\n');
}
} |
920 | ea709b44768aedb9f7d76952f6d5cf3e | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=164-170/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::_resFinished | function | _resFinished() {
const res = this.res;
if (!res || res.finished || (res.connection && res.connection.destroyed)) {
return true;
}
return false;
} |
921 | bdaacb96b10e7f14a7644ac906dc2b06 | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=73-133/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::send | function | /**
* Sends a single SSE event. id and retry are optional, event and data are mandatory.
*
* @param string event: event name, e.g. 'message'
* @param {Object|string} data: event data. this.serialize(data) will be called before sending.
* @param {Object|string} id: event ID. this.s... |
922 | 29ca4e3a526f6e95dfca93dbb5cdaa90 | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=136-161/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::end | function | /**
* Ends the HTTP response.
*/
end() {
if (!this.res) {
return Promise.resolve();
}
if (this._resFinished()) {
delete this.res;
return Promise.resolve();
}
const res = this.res;
delete this.res;
return new Pro... |
923 | 2bccf8834f5a5ae4a60eef783fb0c5fc | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=173-180/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::_sendLines | function | _sendLines(arr, idx) {
idx = idx || 0;
if (idx >= arr.length) {
return Promise.resolve();
}
return this._write(arr[idx])
.then(() => this._sendLines(arr, idx + 1));
} |
924 | aa4aa79b6f81dcaef0a61d6e795b85da | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=183-240/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | SSEResponse::_write | function | /**
* Write the given data to the underlying stream and return
* only once it has been flushed.
*/
_write(data) {
if (data.length === 0) {
return Promise.resolve();
}
return new Promise((resolve, reject) => {
if (this._resFinished()) {
r... |
925 | a848bf94fd3491aa31214946e71a89e0 | swh:1:cnt:cd9fb24c9aedab09e134f2e61f69240a2c66791e;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=244-254/ | b0ee8986f9fa74a7391d5e0f83267a7d2979e479 | kafkasse | analytics | lib/SSEResponse.js | toJSON | function | /**
* Default serialize function for SSE data and id.
* This does JSON.stringify(d) if d is not already a string.
*/
function toJSON(d) {
if (!_.isString(d)) {
d = JSON.stringify(d);
}
return d;
} |
926 | 0533db69a6f4fec4ad0efb7e387a60ca | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=11-17/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | delay | function | /**
* @param {number} ms
* @return {Promise<void>}
*/
function delay(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
} |
927 | ea32fe4fb225c8f97dc639261a0f3dd8 | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=98-139/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | validateAssignments | function | /**
* Checks assignments and makes sure it is either an Array of String
* topic names, or it is an Array of plain objects containing
* topic, partition, and offset|timestamp properties. If neither of these
* conditions is met, this will throw an Error. Otherwise returns true.
* This validates that assignments ar... |
928 | f1e870f66ff9632972e9378a053dd8e4 | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=75-95/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | getAvailableTopics | function | /**
* Return the intersection of existent topics and allowedTopics,
* or just all existent topics if allowedTopics is undefined.
*
* @param {Array} topicsInfo topic metadata object, _metadata.topics.
* @param {Array} allowedTopics topics allowed to be consumed.
* @return {Array} available topics
*/
function... |
929 | eceef631c2007dab0d355b9dc8b85241 | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=51-72/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | createKafkaConsumerAsync | function | /**
* Returns a Promise of a promisified and connected rdkafka.KafkaConsumer.
*
* @param {Object} kafkaConfig
* @return {Promise<KafkaConsumer>} Promisified KafkaConsumer
*/
function createKafkaConsumerAsync(kafkaConfig) {
let topicConfig = {};
if ('default_topic_config' in kafkaConfig) {
topicCon... |
930 | 780c5cf8e0ac13b29e8358319cac2fd4 | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=20-48/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | objectFactory | function | /**
* Converts a utf-8 byte buffer or a JSON string into
* an object and returns it.
*/
function objectFactory(data) {
// if we are given an object Object, no-op and return it now.
if (_.isPlainObject(data)) {
return data;
}
// If we are given a byte Buffer, parse it as utf-8
if (data in... |
931 | a0308ff5541703da05bc00ca2530272a | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=142-175/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | topicsToPartitionAssignment | function | /**
* Given topic names, this will create TopicPartition assignment objects
* for every partition in each topic, with either timestamp: atTimestamp
* or offset: defaultOffset.
*
* @param {Array} topicsInfo topic metadata object, _metadata.topics.
* @param {Array|String} of topics to build TopicPartition assig... |
932 | d44685615fd10eadbfbb3251131c95ec | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=178-242/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | buildAssignmentsAsync | function | /**
* Given an Array of assignments, this will do the following:
*
* - String entries are assumed to be topic names, and will be
* converted to partition assignment objects
* starting from either atTimestamp, or at -1 (latest).
*
* - Object entries with offset already set will be left as they are.
*
* ... |
933 | 0c03a07db96f1bda1003ef1a9662519c | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=245-284/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | assignmentsForTimesAsync | function | /**
* Given a a Kafka assignments array, this will look for any occurances
* of 'timestamp' instead of 'offset'. For those found, it will issue
* a offsetsForTimes request on the kafkaConsumer. The returned
* offsets will be merged with any provided non-timestamp based assignments,
* and returned as a Promise of... |
934 | 0b5f15c4c8840ecd3416ac7e7385d4d6 | swh:1:cnt:44582827a75d0fd516790b90050981b8d1414515;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=287-308/ | 0ae6114218d74f50308efacddb6e8c291f4383d2 | kafkasse | analytics | lib/utils.js | deserializeKafkaMessage | function | /**
* Parses kafkaMessage.message as a JSON string and then
* augments the object with kafka message metadata.
* in the message._kafka sub object.
*
* @param {KafkaMesssage} kafkaMessage
* @return {Object}
*
*/
function deserializeKafkaMessage(kafkaMessage) {
kafkaMessage.message = objectFactory(kafkaMessa... |
935 | 9bd10d1356347ef6cada131c08caa810 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=52-57/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | customDeserializer | function | function customDeserializer(kafkaMessage) {
// deserializer should return a node-rdkafka message,
// with kafkaMessage.message deserialized from the kafka message value.
kafkaMessage.message = customDeserializedMessage;
return kafkaMessage;
} |
936 | 76469e855f762914f255849861ce5089 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=161-163/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | TestKafkaSSEServer::close | function | close() {
this.server.close();
} |
937 | 31bc651ab483cc72d987544f9f168cb5 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=78-154/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | TestKafkaSSEServer::constructor | function | constructor(port) {
this.port = port;
this.server = http.createServer();
this.log = winston.createLogger({
defaultMeta: {name: 'KafkaSSETest'},
level: logLevel,
format: ecsFormat(),
transports: new winston.transports.Console()
});
... |
938 | 97127c063e4b9f76361e5cd8f069ade1 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=156-159/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | TestKafkaSSEServer::listen | function | listen() {
this.log.debug('Listening for SSE requests on port ' + this.port);
this.server.listen(this.port);
} |
939 | 5ba239fc93b894e363d5d1f7e7ac40d1 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=60-68/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | customFilterer | function | function customFilterer(kafkaMessage) {
// only return message with id == 2.
if (kafkaMessage.message.id == 2) {
return true;
}
else {
return false;
}
} |
940 | b33cbc758ba73c366521ef725e1d6c75 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=189-215/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | httpRequestAsync | function | /**
* Returns a promise of an HTTP request to an SSE endpoint.
* Useful for checking http response status of the SSE request.
*/
function httpRequestAsync(port, route, topics, last_event_id) {
if (_.isArray(topics)) {
topics = topics.join(',');
}
let headers = {
'Accept': 'text/event-str... |
941 | 360b876380625496604021b08df8b226 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=218-263/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | sseRequest | function | /**
* Creates a new EventSource by connecting to an SSE endpoint.
* msgCb will be called for each onmessage event, and errCb
* will be called for each onerror event. This returns
* the new EventSource with the onmessage and onerror handlers
* registered. msgCb will be given the SSE event object.
*
*/
function ... |
942 | 0cc732dab6497c5fc5a3d26badee398b | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=266-275/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | spyWithCb | function | /**
* Returns a Sinon spy that will call fn(spy) whenever
* the spy is called.
*/
function spyWithCb(fn) {
let spy = sinon.spy(() => {
return fn(spy);
});
return spy;
} |
943 | 6190a46e135d3fc5512bf74d419d2aa7 | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=277-295/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | assertMessagesConsumedSpy | function | /**
* Returns a spy function that once called shouldConsumeOffsets.length times,
* will assert that kafkaMessages consumed thus far contain the offsets in
* shouldConsumeOffsets array. Then calls done();
*/
function assertMessagesConsumedSpy(shouldConsumeOffsets, done) {
let callCountShouldBe = shouldConsumeOf... |
944 | f0583f5c08307347e8a7a3b366956a0a | swh:1:cnt:ed013daf3120179df266a877dc41b5df34b63e5f;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=70-164/ | 9153c0be827d8dc6fee12e4f0f9f2c07184387e5 | kafkasse | analytics | test/KafkaSSE.js | TestKafkaSSEServer | type | /**
* KafkaSSE test server.
* Connect to this with a client on port.
* Kafka broker must be running at `kafkaBroker`
* initialized variable value.
*/
class TestKafkaSSEServer {
constructor(port) {
this.port = port;
this.server = http.createServer();
this.log = winston.createLogger({
... |
945 | eb6efdc8249fa6545ec17fe5f3e5dea8 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=13-36/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | TestSSEServer | type | /**
* Responds to http requests like: /:n, where n is the number of messages
* that should be sent back to the SSE client.
*/
class TestSSEServer {
constructor(port, responseOptions, messageBuilder) {
this.server = http.createServer();
this.port = port || defaultPort;
this.messageBuilder ... |
946 | 938a38fc861765c3bbf930317ea25b6f | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=108-150/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock | type | class HTTPResponseMock {
constructor() {
this.written = [];
this.finished = false;
}
writeHead(httpCode, headers) {
this.httpCode = httpCode;
this.headers = headers;
}
write(text) {
this.written.push(text);
return true;
}
headersSent() {
... |
947 | 959158e7698d7b541ec0f9ceee961c50 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=18-27/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | TestSSEServer::constructor | function | constructor(port, responseOptions, messageBuilder) {
this.server = http.createServer();
this.port = port || defaultPort;
this.messageBuilder = messageBuilder || defaultMessageBuilder;
this.server.on('request', (req, res) => {
const messageCount = req.url.replace('/', '');
... |
948 | 835448e980f97cd5158466bf1eae1ee2 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=38-40/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | defaultMessageBuilder | function | function defaultMessageBuilder(id) {
return ['message', 'data: ' + id];
} |
949 | b99faa043612267afb7276f95c936721 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=42-44/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | objectMessageBuilder | function | function objectMessageBuilder(id) {
return ['message', {'data': id}];
} |
950 | 76469e855f762914f255849861ce5089 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=33-35/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | TestSSEServer::close | function | close() {
this.server.close();
} |
951 | cda23c8948ddb6c2959ee4167528f698 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=29-31/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | TestSSEServer::listen | function | listen() {
return this.server.listen(this.port);
} |
952 | 9a05cfd78f0b66cfc43b023a1f8b2933 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=46-53/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | sendN | function | function sendN(sse, messageBuilder, n, idx) {
if (n <= idx) {
return Promise.resolve();
}
const msg = messageBuilder(idx);
return sse.send(msg[0], msg[1], idx, 1000)
.then(() => sendN(sse, messageBuilder, n, idx + 1));
} |
953 | 53555d8caa2f1c1a04770fb356f1cafd | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=55-63/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | sseSendN | function | /**
* Creates a new SSEResponse object and sends n messages.
*/
function sseSendN(res, n, options, messageBuilder) {
let sseResponse = new SSEResponse(res, options);
sseResponse.start()
.then(() => sendN(sseResponse, messageBuilder, n, 0))
.then(() => sseResponse.end());
} |
954 | 1cbf4b01c3632bf26f45110f23bd95b9 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=65-79/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | httpRequestAsync | function | /**
* Returns a promise of an HTTP request to an SSE endpoint.
* Useful for checking http response status of the SSE request.
*/
function httpRequestAsync(port, path) {
let headers = {
'accept': 'text/event-stream',
'cache-control': 'no-cache',
};
return fetch(
`http://localhost:... |
955 | 48ec691199e77e51b33f99bcaa62297a | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=81-106/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | sseRequest | function | /**
* Uses EventSource to emit events sent from TestSSEServer.
* msgCb will be called on message, and errCb onerror.
*/
function sseRequest(port, path, msgCb, errCb) {
const url = `http://localhost:${port}/${path}`;
let es = new EventSource(url);
// If error callback is not given, then just throw the ... |
956 | 4e1d756d921883307049366ab028bb3d | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=109-112/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::constructor | function | constructor() {
this.written = [];
this.finished = false;
} |
957 | 5d9f4333527181a102c59ff869904d3d | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=114-117/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::writeHead | function | writeHead(httpCode, headers) {
this.httpCode = httpCode;
this.headers = headers;
} |
958 | 4f0d7b6c3b9ece615849650368d9a3a5 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=119-122/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::write | function | write(text) {
this.written.push(text);
return true;
} |
959 | c95f182f3d5e1e39cbf1b08b54dc5652 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=132-134/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::once | function | once(event, cb) {
// do nothing
} |
960 | 9b97e767ad10c0e2de9e0a93c47c30b3 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=140-142/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::finished | function | finished() {
return this.finished;
} |
961 | 2b289c320df270952d3feee9b66b321c | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=128-130/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::on | function | on(event, cb) {
// do nothing
} |
962 | c99709b425aad47f28e6c024d50511b2 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=144-149/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::end | function | end(cb) {
this.finished = true;
if (cb) {
cb();
}
} |
963 | 7f5743297931351748a64ebcaaa32ee3 | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=136-138/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::removeListener | function | removeListener(event, cb) {
// do nothing
} |
964 | e92d5f61c0a9eb36337cbb75ca78163a | swh:1:cnt:1e11ac086ab8711a04a21bed47470a0895dc6e77;origin=https://gitlab.wikimedia.org/repos/data-engineering/kafkasse.git;lines=124-126/ | cf247600e1a783382343868faf2e955691323377 | kafkasse | analytics | test/SSEResponse.js | HTTPResponseMock::headersSent | function | headersSent() {
return this.headers !== undefined;
} |
965 | 4421e4050a86d51f5894bef91bb8ae48 | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=39-83/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | registerKafkaLogHandler | function | /**
* Registers node-rdkafka event.error and event.log events
* to be logged appropriately by the provided bunyan logger.
* Log events will not be logged unless event_cb: true is set
* in kafka client config.
* To use this well, you should also set kafka.conf.log_level (to get rdkafka to log things)
* and/or kafk... |
966 | e9f6057de9cdd0501e507993f1b4c355 | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=86-127/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | producerFactory | function | /**
* Returns a Promise of a connected Kafka Producer ready for producing.
* A hasty producer does not use a delivery callback, and will not wait
* for delivery confirmation before resolving a produce promise, while
* a guaranteed producer type will.
* @param {string} ProducerClass One of GuaranteedProducer or Ha... |
967 | e887f224ac30752a8c1b44778b9ee913 | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=158-173/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | GuaranteedProducer::constructor | function | /**
* @inheritdoc
*/
constructor(conf, topicConf) {
// GuaranteedProducer required dr_cb is true to use delivery-report.
conf.dr_cb = true;
super(conf, topicConf);
this.on('delivery-report', (err, report) => {
const reporter = report.opaque;
if (err... |
968 | 836a960ea407f378a32d427ae892dfbd | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=145-156/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | GuaranteedProducer::factory | function | /**
* Returns a Promise of a connected Kafka GuaranteedProducer ready for producing.
* @param {Object} config Kafka config. Additional custom config `producer.poll.interval.ms`
* controls the value used for producer.setPollInterval.
* producer.poll.i... |
969 | ee74b795fe811d48b59019257bb34a8c | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=129-138/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | transformHeaders | function | /**
* Transform an object of headers into the format expected by node-rdkafka,
* i.e. an array of objects with a single key and value each.
*
* @param {Object?} headers
* @return {Array} Array of objects with key and value properties.
*/
function transformHeaders(headers) {
return Object.entries(headers ?? {}).... |
970 | f8e56d3107c7c4dbf61bbbe4ec4682c8 | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=175-207/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | GuaranteedProducer::produce | function | /**
* @param {string} topic
* @param {number | null | undefined} partition
* @param {kafka.MessageValue} message
* @param {kafka.MessageKey | undefined} key
* @param {number | null | undefined} timestamp
* @param {Record<string, string> | undefined} headers
*/
produce(topic, parti... |
971 | da1d75811bb3235c3832b8b0d4dd552d | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=219-231/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | HastyProducer::factory | function | /**
* Returns a Promise of a connected Kafka HastyProducer ready for producing.
*
* @param {Object} config Kafka config. Additional custom config `producer.poll.interval.ms`
* controls the value used for producer.setPollInterval.
* producer.poll... |
972 | 9128cb1945e21b07ad819ef411d2410d | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=233-255/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | HastyProducer::produce | function | /**
* @param {string} topic
* @param {number | null | undefined} partition
* @param {kafka.MessageValue} message
* @param {kafka.MessageKey | undefined} key
* @param {number | null | undefined} timestamp
* @param {Record<string, string> | undefined} headers
*/
produce(topic, parti... |
973 | 510e61efd77e04fb10e7b0f651e3178c | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=140-208/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | GuaranteedProducer | type | /**
* Uses the node-rdkafka delivery-report callback to resolve the produce call Promise
* based on the Kafka broker delivery status.
*/
class GuaranteedProducer extends kafka.Producer {
/**
* Returns a Promise of a connected Kafka GuaranteedProducer ready for producing.
* @param {Object} config Kafka... |
974 | b2a3090dfc1f5c84d83b48b7f98baea4 | swh:1:cnt:1de9816305346f49935ac1139794617853328fd1;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-factory.git;lines=210-256/ | cfcdc08759bea9acc991d47decf5b37e8c585ec8 | node-rdkafka-factory | analytics | index.js | HastyProducer | type | /**
* Resolves a produce call Promise as soon as node-rdkafka accepts the produce request.
* This producer will not wait for a delivery report for the message and
* therefore also does not accept an `opaque` parameter to be passed to the
* delivery report callback.
* Use {@link GuaranteedProducer} if you want to c... |
975 | 96597398a9265b722bfa4f02f6953398 | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=24-24/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | conf | type | struct conf |
976 | 45f6d0929bc11de9bc7a9cc3db3738be | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=212-212/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | conf_set::iovec | type | struct iovec |
977 | f6a716c022ae3b11655da265c3b5c84f | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=60-67/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | encoding_parse(const char *val) | function | static encoding_t encoding_parse (const char *val) {
if (!strcasecmp(val, "string"))
return ENC_STRING;
else if (!strcasecmp(val, "json"))
return ENC_JSON;
else
return ENC_ERROR;
} |
978 | 2f3bb2e03fb92aad6d3f6932c48baeb5 | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=40-58/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | conf_tof(const char *val) | function | /**
* Parses the value as true or false.
*/
static int conf_tof (const char *val) {
char *end;
int i;
i = strtoul(val, &end, 0);
if (end > val) /* treat as integer value */
return !!i;
if (!strcasecmp(val, "yes") ||
!strcasecmp(val, "true") ||
!strcasecmp(val, "on") ||
!*val /* empty value is... |
979 | ee271ed4efcf22e3e20f46d973da9797 | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=136-174/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | input_kvs_parse(char *str, encoding_t *encp, int *flagsp,
char *errstr, size_t errstr_size) | function | /**
* Parse input key-values.
*/
static int input_kvs_parse (char *str, encoding_t *encp, int *flagsp,
char *errstr, size_t errstr_size) {
const char *kv_n, *kv_v;
while (kv_parse(&str, &kv_n, &kv_v)) {
if (!strcmp(kv_n, "encoding")) {
if ((*encp = encoding_parse(kv_v)) == ENC_ERROR) {
snprintf(er... |
980 | a00bb4fbc4ffb1aadb77374ae2ef2163 | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=177-356/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | conf_set(const char *name, const char *val,
char *errstr, size_t errstr_size,
void *opaque) | function | /**
* Set a single configuration property 'name' using value 'val'.
* Returns 0 on success, and -1 on error in which case 'errstr' will
* contain an error string.
*/
int conf_set (const char *name, const char *val,
char *errstr, size_t errstr_size,
void *opaque) {
rd_kafka_conf_res_t res;
/* Kafka ... |
981 | 7fd2a627ac0dab9c95b9975d2bbfcfcb | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=69-92/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | str_unescape(char *str) | function | static char *str_unescape (char *str) {
char *s = str;
while (*s) {
int esc = -1;
if (!strncmp(s, "\\n", 2))
esc = '\n';
else if (!strncmp(s, "\\r", 2))
esc = '\r';
else if (!strncmp(s, "\\t", 2))
esc = '\t';
else if (!strncmp(s, "\\0", 2))
esc = '\0';
if (esc != -1) {
*s = esc;
memmov... |
982 | e3ffb769e02be5c2b882ca6c83e36d2b | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=29-36/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | ltrim(const char *s) | function | /* Left trim string '*s' of white spaces and return the new position.
* Does not modify the string. */
static char *ltrim (const char *s) {
while (isspace(*s))
s++;
return (char *)s;
} |
983 | 5d6f5e3a8989a3a88f835ab157a5c9ab | swh:1:cnt:e85e571f27e146cdef4e54cf8f05986e0744d5da;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=94-133/ | e3c6083d487ae0b5badd3c0054985d7417440c56 | kafkatee | analytics | config.c | kv_parse(char **strp, const char **namep, const char **valp) | function | /**
* Parses a "k=v,k2=v2,.." string in 'str' (which is modified)
* and returns 1 on match, else 0.
* Key name and value are returned in 'namep' and 'valp'.
* If no value if specified (and no '='), then value is set to "".
* '*strp' is forwarded to the next token on return for a sub-sequent
* call to kv_parse() (... |
984 | ecdd67f641b0a0902cd14ef5f2112d10 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=45-54/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc | type | /**
* Keeps track of spawned child processes.
*/
struct child_proc {
LIST_ENTRY(child_proc) link;
pid_t pid;
char *cmd;
time_t t_start;
int *statusp;
} |
985 | a43773a7c8ce4ac8cd125f3cde826564 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=98-98/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_find::child_proc | type | struct child_proc |
986 | a43773a7c8ce4ac8cd125f3cde826564 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=87-87/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_del::child_proc | type | struct child_proc |
987 | a43773a7c8ce4ac8cd125f3cde826564 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=69-69/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_add::child_proc | type | struct child_proc |
988 | 3e98ea5fa6bd88165a0e3a30924c0507 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=124-124/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | kt_popen::sigaction | type | struct sigaction |
989 | a43773a7c8ce4ac8cd125f3cde826564 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=246-246/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_reap::child_proc | type | struct child_proc |
990 | a43773a7c8ce4ac8cd125f3cde826564 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=286-286/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | exec_main::child_proc | type | struct child_proc |
991 | bcd4d2854ee23ced50dbb4ae09ac3c07 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=205-231/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | exec_exitstatus(int status) | function | /**
* Returns a human readable process exit reason based on the exit code.
*/
const char *exec_exitstatus (int status) {
static __thread char ret[128];
if (WIFEXITED(status)) {
if (WEXITSTATUS(status) == 127)
snprintf(ret, sizeof(ret),
"could not execute command");
else
snprintf(ret, sizeof(ret), "e... |
992 | b32ad527e2e28afaea3a5296ca1ad88a | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=83-92/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_del(struct child_proc *cp) | function | /**
* Removes a child proc from the list.
* NOTE: child_proc_lock must be held
*/
static void child_proc_del (struct child_proc *cp) {
LIST_REMOVE(cp, link);
free(cp->cmd);
free(cp);
atomic_sub(&child_proc_cnt, 1);
} |
993 | 571688841389236f427789f5ae1c6067 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=234-269/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_reap(void) | function | /**
* Called from non-signal context to reap any child processes that
* might have died lately.
*/
static void child_proc_reap (void) {
pid_t pid;
int st;
atomic_set(&do_child_proc_reap, 0);
pthread_mutex_lock(&child_proc_lock);
while ((pid = waitpid(-1, &st, WNOHANG)) > 0) {
struct child_proc *cp;
cp = ... |
994 | 2783fb05c402468576234934b9c7d344 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=332-338/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | exec_term(void) | function | /**
* Terminate child process exec layer
*/
void exec_term (void) {
void *ignore;
pthread_join(exec_thread, &ignore);
} |
995 | 1cc4f2cd91e21109314a356b060124a9 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=341-352/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | exec_init(void) | function | /**
* Initialize child process exec layer
*/
void exec_init (void) {
int err;
if ((err = pthread_create(&exec_thread, NULL, exec_main, NULL))) {
kt_log(LOG_ERR,
"Failed to create exec_main thread: %s", strerror(err));
exit(1);
}
} |
996 | 45f5cda51bc0ede5ab37dbb88e76e2a7 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=272-275/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | sigchld(int sig) | function | static void sigchld (int sig) {
/* Simply indicate to non-signal context to reap the child proc */
atomic_set(&do_child_proc_reap, 1);
} |
997 | 173a4bd5c9eb143e3501c39bc9c531ff | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=64-80/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_add(const char *cmdstring, pid_t pid, int *statusp) | function | /**
* Adds a child process to the list of known child processes.
* NOTE: child_proc_lock must be held
*/
static void child_proc_add (const char *cmdstring, pid_t pid, int *statusp) {
struct child_proc *cp;
cp = calloc(1, sizeof(*cp));
cp->cmd = strdup(cmdstring);
cp->pid = pid;
cp->t_start = time(NU... |
998 | 6c72b4c052079734614847f7f411d51c | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=109-201/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | kt_popen(const char *cmdstring, const char *rw,
pid_t *pidp, int *statusp,
char *errstr, size_t errstr_size) | function | /**
* Similar to popen() but uses file descriptors instead of streams and
* returns the child process' pid in '*pidp'.
* 'statusp' is a pointer to where the child's exit status will be stored
* if the child terminates. The caller should set 'statusp' to -1 prior
* to calling kt_open, -1 indicates that pipe is stil... |
999 | 9df5652d08c3f8ab7558edf98db10655 | swh:1:cnt:b699292a5b68ec384b0cf5e56906116a6cf80ce1;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=94-106/ | 95f025dba8c40a524ab8c609762334e27a5415d6 | kafkatee | analytics | exec.c | child_proc_find(pid_t pid) | function | /**
* Finds a child proc based on its pid.
* NOTE: child_proc_lock must be held
*/
static struct child_proc *child_proc_find (pid_t pid) {
struct child_proc *cp;
LIST_FOREACH(cp, &child_procs, link)
if (cp->pid == pid)
return cp;
return NULL;
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.