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 |
|---|---|---|---|---|---|---|---|---|---|
1,100 | 8caf4eefa5de3a507fcc892d8440ab13 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=204-214/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | fmt | type | /**
* Formatting from format
*/
struct fmt {
int idx; /* fmt[] array index */
int varidx; /* fmtvar index (non-zero if formatter is a var) */
const char *def; /* default string, typically "-" */
int deflen; /* default string's length */
int flags;
#define FMT_F_ESCAPE 0x1 /* Escape the... |
1,101 | 34392d710c5a28cc3988e95b257ca446 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=120-122/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | input_s::cmd | type | struct {
char *cmd;
} |
1,102 | fa58a638c2f66c6d022f00af774616f8 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=123-129/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | input_s::topic | type | struct {
char *topic;
int partition;
int64_t offset;
rd_kafka_topic_t *rkt;
int terminate;
} |
1,103 | 4e5135d8dbe3f4ce2962d34b9b534c46 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=147-181/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | output_s | type | struct output_s {
LIST_ENTRY(output_s) o_link;
int o_id;
char *o_name;
output_type_t o_type;
int o_sample_rate;
uint64_t o_c_rx; /* number of received messages */
uint64_t o_c_tx; /* number of transmitted messages */
uint64... |
1,104 | f3f832b9e6a85f2d4f4957681a70e73d | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=260-260/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | conf::fmt_conf | type | struct fmt_conf |
1,105 | a9a979ae690491db6d49c219d2e0aaaa | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=253-297/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | conf | type | /**
* kafkatee configuration container
*/
struct conf {
char *output_delimiter; /* Output delimiter */
int output_delimiter_len;
struct fmt_conf fconf; /* Output format */
int output_queue_size; /* Per-output queue size */
int input_queue_siz... |
1,106 | c3732260de9c55494bc82f4b716ca349 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=83-89/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | msgq_s | type | struct msgq_s {
TAILQ_HEAD(, msg_s) mq_msgs;
int mq_msgcnt;
pthread_mutex_t mq_lock;
pthread_cond_t mq_cond;
time_t mq_t_write; /* Time of last fd write */
} |
1,107 | 6852fa39016772c4dfee9950e6e6d7bb | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=76-81/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | msg_s | type | struct msg_s {
TAILQ_ENTRY(msg_s) m_link;
msgpayload_t *m_mp;
struct iovec m_iov[2];
int m_iovcnt;
} |
1,108 | a8be825cc675431623df44dcb9203e80 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=217-234/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | fmt_conf | type | /**
* Formatter configuration
*/
struct fmt_conf {
encoding_t encoding;
/* Array of formatters in output order. */
struct fmt *fmt;
int fmt_cnt;
int fmt_size;
/* Array of fmtvars */
struct fmtvar *fmtvar;
int fmtvar_cnt;
int fmtvar_size;
char *format;
} |
1,109 | 91f5763000a44eb9f21917c11b658584 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=229-229/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | fmt_conf::fmtvar | type | struct fmtvar |
1,110 | d0d685491658581fe48562b4d1cd9b20 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=238-249/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | render | type | /**
* Formatter renderer
*/
struct render {
const struct fmt_conf *fconf;
struct fmtval *fmtval; /* Variables' values */
/* Value scratch buffer */
char *scratch;
int scratch_of;
int scratch_size;
} |
1,111 | 1ac1c623d19c450170421cf9ef06ddd1 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=69-74/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | msgpayload_s | type | struct msgpayload_s {
struct iovec mp_iov[2];
int mp_iovcnt;
int mp_refcnt;
rd_kafka_message_t *mp_rkm;
} |
1,112 | 45f6d0929bc11de9bc7a9cc3db3738be | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=70-70/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | msgpayload_s::iovec | type | struct iovec |
1,113 | 45f6d0929bc11de9bc7a9cc3db3738be | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=79-79/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | msg_s::iovec | type | struct iovec |
1,114 | 99febf706bfa782d288ea8db49816764 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=94-97/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | INPUT_PIPE | type | enum {
INPUT_PIPE,
INPUT_KAFKA,
} |
1,115 | 05f0ebda6d925b5395c9d8caef00089d | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=185-192/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | fmtvar | type | /**
* Formatting variable (%{VAR})
*/
struct fmtvar {
const char *var;
int varlen;
int idx;
} |
1,116 | d82921495ca4b44e41f3b9b7586f8c9c | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=142-145/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | OUTPUT_PIPE | type | enum {
OUTPUT_PIPE,
OUTPUT_FILE,
} |
1,117 | 9654bd1182f6520572d4747fd2082ba5 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=224-224/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | fmt_conf::fmt | type | struct fmt |
1,118 | 0516e8face8f4bdb13d1e23dc78e3731 | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=194-201/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | fmtval | type | /**
* Formatting value
*/
struct fmtval {
char *val;
int vallen;
int seen;
} |
1,119 | f3f832b9e6a85f2d4f4957681a70e73d | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=242-242/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | render::fmt_conf | type | struct fmt_conf |
1,120 | 2583eb617ad85f03376f406471f4515d | swh:1:cnt:235ad5c2c1e535e23718c9c6ae982081be7c735c;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=243-243/ | f582e7f7c82152d949eb24917e691f158f14e424 | kafkatee | analytics | kafkatee.h | render::fmtval | type | struct fmtval |
1,121 | 944b14e9ad6568d3e40dd9a75dd8ccbb | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=73-86/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_msgpayload_enq(msgpayload_t *mp) | function | /**
* Attempt to enqueue msgs based on the msgpayload on all outputs.
*/
int outputs_msgpayload_enq (msgpayload_t *mp) {
output_t *o;
int cnt = 0;
LIST_FOREACH(o, &outputs, o_link) {
if (output_msgpayload_enq(o, mp) != -1)
cnt++;
}
return cnt;
} |
1,122 | 063411686c40e2a741472fd5864e225c | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=89-96/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_cmp(void *_a, void *_b) | function | /**
* Output comparator for sorting: sort ascendingly on sample_rate
*/
static int output_cmp (void *_a, void *_b) {
output_t *a = _a, *b = _b;
return a->o_sample_rate - b->o_sample_rate;
} |
1,123 | 08c5ee04d7ec89f72be21a0214dd05cf | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=140-213/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_open(output_t *o) | function | /**
* Open/start output.
*/
int output_open (output_t *o) {
int fd = -1;
struct epoll_event ev = {};
int r;
char errstr[512];
_DBG("Opening output \"%s\"", o->o_name);
assert(o->o_fd == -1);
switch (o->o_type)
{
case OUTPUT_PIPE:
o->o_pipe.status = 0;
if ((fd = kt_popen(o->o_pipe.cmd, "w",
&o->... |
1,124 | e520277848fc928864dd8cba5b7a82c9 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=320-334/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_write(output_t *o) | function | /**
* Write as many messages to file descriptor from outq as possible.
* Propogate errors to caller.
*/
static int output_write (output_t *o) {
int r;
if (unlikely(o->o_fd == -1))
return -1;
while ((r = output_write0(o)) > 0)
;
return r;
} |
1,125 | a0fd91fc28bcc02b4e5c98e71afa9e40 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=338-384/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_check(void) | function | /**
* Check if any outputs needs starting/opening.
*/
static void outputs_check (void) {
output_t *o;
time_t now = time(NULL);
int totqcnt = 0;
LIST_FOREACH(o, &outputs, o_link) {
#if 0 /* Output queue pressure debugging */
_DBG("\"%s\" queue pressure: %i (rx %"PRIu64", tx %"PRIu64
", tx qdrop %"PRIu64... |
1,126 | 63c6f0d515155d4ba08ba8773ebbbdaa | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=411-470/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_main(void *ignore) | function | /**
* The outputs thread main loop.
*/
static void *outputs_main (void *ignore) {
struct epoll_event *ev;
time_t t_last_check = 0;
output_t *o;
static int our_rotate_version = 0;
/* Block all signals in this thread */
ezd_thread_sigmask(SIG_BLOCK, 0/*ALL*/, -1/*end*/);
ev = malloc(sizeof(*ev) * outputs_cnt);... |
1,127 | f4a7823596d71148a9b3bed6424f791b | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=55-70/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_msgpayload_enq(output_t *o, msgpayload_t *mp) | function | /**
* If output is eligible for a message (according to queue pressure and
* its configured sample-rate) then create a new message shadowing the
* msgpayload and enqueue it on the output's output queue.
*/
static int output_msgpayload_enq (output_t *o, msgpayload_t *mp) {
msgq_lock(&o->o_outq);
if (o->o_outq.m... |
1,128 | 9992aaaad51c9efbffd2083be82277ca | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=99-136/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_add(output_type_t type, int sample_rate, const char *cmd) | function | /**
* Add a new output.
* This must only be done during initial setup and is typically done
* by the config file reader.
*/
output_t *output_add (output_type_t type, int sample_rate, const char *cmd) {
output_t *o;
o = calloc(1, sizeof(*o));
o->o_id = conf.output_id_next++;
o->o_type = type;
o... |
1,129 | f27d7f4670f9af583831285719cd1590 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=217-247/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_close(output_t *o, int level, const char *reason) | function | /**
* Close/stop an output.
*/
void output_close (output_t *o, int level, const char *reason) {
if (o->o_fd == -1)
return;
kt_log(level, "Closing output \"%s\": %s (%i messages in queue)",
o->o_name, reason, o->o_outq.mq_msgcnt);
epoll_ctl(outputs_epoll_fd, EPOLL_CTL_DEL, o->o_fd, NULL);
switch (o->... |
1,130 | d150d86356d67b7b2465f975f0fc23a1 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=251-317/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_write0(output_t *o) | function | /**
* Attempts to write as many messages as possible from the output's out queue
* to the output fd.
* Returns 1 if more messages can be written, 0 if not, or -1 on error.
*/
static int output_write0 (output_t *o) {
struct iovec iov[IOV_MAX];
int i = 0;
ssize_t r;
msg_t *m, *mtmp;
/* Collect messages into iov... |
1,131 | 15efed749ba653ae18da5e2c24aa32a3 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=388-408/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_rotate(void) | function | /**
* Output rotation:
* Close all outputs and open them again.
*/
static void outputs_rotate (void) {
output_t *o;
kt_log(LOG_INFO, "Rotating %i outputs", outputs_cnt);
LIST_FOREACH(o, &outputs, o_link) {
/* Close output */
if (o->o_fd != -1)
output_close(o, LOG_DEBUG, "rotate");
/* Reset open_fail t... |
1,132 | 777735df06d13db6568bc29dbfc7e031 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=473-479/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_term(void) | function | /**
* Terminate outputs sub-system
*/
void outputs_term (void) {
void *ignore;
pthread_join(outputs_thread, &ignore);
} |
1,133 | 523c29d8657c62349379be63221b626f | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=481-500/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_start(void) | function | /**
* Initialize outputs sub-system
*/
void outputs_start (void) {
/* Create epoll handle */
outputs_epoll_fd = epoll_create1(EPOLL_CLOEXEC);
if (outputs_epoll_fd == -1) {
kt_log(LOG_CRIT, "Failed to create epoll fd: %s",
strerror(errno));
exit(1);
}
/* Start outputs thread */
if (pthread_create(... |
1,134 | c2af03cfdad2b27ebdd3d6f15f2c10e1 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=145-145/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_open::epoll_event | type | struct epoll_event |
1,135 | 45f6d0929bc11de9bc7a9cc3db3738be | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=257-257/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | output_write0::iovec | type | struct iovec |
1,136 | c2af03cfdad2b27ebdd3d6f15f2c10e1 | swh:1:cnt:53798cc6edfd2edd701e40957f942523c22ab848;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=415-415/ | 84ad594696ed843b2e6fb2683d77dce2cffa6330 | kafkatee | analytics | output.c | outputs_main::epoll_event | type | struct epoll_event |
1,137 | cfd199e759a6b54edbfd38703c0a01dd | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=67-127/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msgpayload_new(input_t *in, void *payload, size_t len,
rd_kafka_message_t *rkm) | function | /**
* Create new sharable msgpayload.
* Performs payload transformation according to configuration.
*/
msgpayload_t *msgpayload_new (input_t *in, void *payload, size_t len,
rd_kafka_message_t *rkm) {
msgpayload_t *mp;
void *final_payload;
size_t final_len;
int extra_delim = 0;
atomic_add(&in->in_c_rx,... |
1,138 | 2e5cefb7928b3cde7a5a429f040985ec | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=58-64/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msg_destroy(msg_t *m) | function | /**
* Unref message's msgpayload and free 'm'.
*/
void msg_destroy (msg_t *m) {
msgpayload_destroy(m->m_mp);
free(m);
} |
1,139 | d7ad9d026a9163146b716d766ec07bb4 | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=146-153/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msgq_enq(msgq_t *mq, msg_t *m) | function | /**
* Enqueue message on queue.
* NOTE: msgq must be locked
*/
void msgq_enq (msgq_t *mq, msg_t *m) {
TAILQ_INSERT_TAIL(&mq->mq_msgs, m, m_link);
mq->mq_msgcnt++;
} |
1,140 | 3fc6a5c36f49c3d695e53f41bdadb7a3 | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=166-172/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msgq_init(msgq_t *mq) | function | /**
* Initialize message queue.
*/
void msgq_init (msgq_t *mq) {
TAILQ_INIT(&mq->mq_msgs);
mq->mq_msgcnt = 0;
} |
1,141 | 1982e6c8b5a3c15c971fd0e28f199e85 | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=41-56/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msgpayload_destroy(msgpayload_t *mp) | function | /**
* Unref msgpayload, free it if refcnt reaches 0.
*/
void msgpayload_destroy (msgpayload_t *mp) {
if (atomic_sub(&mp->mp_refcnt, 1) > 0)
return;
if (mp->mp_rkm)
rd_kafka_message_destroy(mp->mp_rkm);
else
free(mp->mp_iov[0].iov_base);
free(mp);
atomic_sub(&msgs_cnt, 1);
} |
1,142 | bf02e963cb447f3432a4ce685e0317eb | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=130-143/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msg_new(msgpayload_t *mp) | function | /**
* Create a message pointing to the provided payload
*/
msg_t *msg_new (msgpayload_t *mp) {
msg_t *m;
m = malloc(sizeof(*m));
m->m_mp = mp;
memcpy(m->m_iov, mp->mp_iov, sizeof(*mp->mp_iov) * mp->mp_iovcnt);
m->m_iovcnt = mp->mp_iovcnt;
atomic_add(&mp->mp_refcnt, 1);
return m;
} |
1,143 | 68807ea19db95667e493628320ffaef7 | swh:1:cnt:d2899151b655d6a6f4888592d0ad77caf0d0253d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=155-163/ | 8872e956e6b2d3d650bbc115e1c3754b4efd44d3 | kafkatee | analytics | queue.c | msgq_deq(msgq_t *mq, msg_t *m) | function | /**
* Dequeue message from queue.
* NOTE: msgq must be locked
*/
void msgq_deq (msgq_t *mq, msg_t *m) {
assert(mq->mq_msgcnt > 0);
TAILQ_REMOVE(&mq->mq_msgs, m, m_link);
mq->mq_msgcnt--;
} |
1,144 | 7d408fad46c1805ccad4186d44e1677f | swh:1:cnt:bdd4bed1a561121818a2db1c19ca3fe24e8d99b9;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=42-62/ | bad56492f6d49c23208a22bb69a6a688fa35699f | kafkatee | analytics | test/ingen.c | main(int argc, char **argv) | function | int main (int argc, char **argv) {
int cnt;
char buf[] = "This is just a test line\n";
int len = strlen(buf);
if (argc < 2) {
printf("Usage: %s <linecnt>\n", argv[0]);
exit(1);
}
cnt = atoi(argv[1]);
while (cnt-- > 0)
if (fwrite(buf, 1, len, stdout) == -1) {
perror("write error");
exit(1);
}
... |
1,145 | 9fdeeaccc830d3ae7a889bbbb1947032 | swh:1:cnt:06bf70eaccd3146c5ff8c5f04fbb219e459a3ebb;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=41-44/ | 417c675ce9e4d7c2104569bfd15fdba32576dcf6 | kafkatee | analytics | test/linecnt.c | do_timeout(int sig) | function | static void do_timeout (int sig) {
run = 0;
fclose(stdin); /* trigger fgets() to quit */
} |
1,146 | f640543f49a0163edd3e550d5125549f | swh:1:cnt:06bf70eaccd3146c5ff8c5f04fbb219e459a3ebb;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=46-85/ | 417c675ce9e4d7c2104569bfd15fdba32576dcf6 | kafkatee | analytics | test/linecnt.c | main(int argc, char **argv) | function | int main (int argc, char **argv) {
int cnt = 0;
int expected;
int sleeptime = 5;
int endtime = 0;
char buf[4096];
if (argc < 3) {
printf("Usage: %s <expected-number-of-lines-to-read> "
" <timeout> "
" [<sleep-time-after-expected-reached>]\n", argv[0]);
exit(1);
}
expected = atoi(argv[1])... |
1,147 | 7939db88056cc418e07525f5f4d32d95 | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=54-58/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | fatal(str) | function | def fatal (str):
global failures
failures += 1
raise Exception('\033[31mTEST:%s: FAILED: %s\033[0m' % \
(threading.current_thread().name, str)) |
1,148 | ddbdeb0cb01d836f27f0a947519a545b | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=94-97/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | input_generator_start() | function | def input_generator_start ():
thr = threading.Thread(None, input_generator_main, 'inputgen')
thr.daemon = True
thr.start() |
1,149 | 0baba2ea5a04d60b6478e70ba06f42a5 | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=208-213/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | output_checker_start(o) | function | def output_checker_start (o):
thr = threading.Thread(None, output_checker_main, 'output ' + o['fifo'],
(o,))
thr.daemon = False
thr.start()
return thr |
1,150 | a496099dc07ffdba2d44bedb3d9f9a0c | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=50-52/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | log(str) | function | def log (str):
sys.stderr.write('\033[33mTEST:%s: %s\033[0m\n' % \
(threading.current_thread().name, str)) |
1,151 | db5738079e637c3b541290ca49e1d9ff | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=61-91/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | input_generator_main() | function | def input_generator_main ():
global test_id
log('started input generator, will generate seqs %i .. %i' %
(args.seq, args.seq_hi))
cnt = 0
for seq in range(args.seq, args.seq_hi):
obj = json_obj
obj['seq'] = seq
obj['field1'] = test_id
obj['field4'] = seq
... |
1,152 | 289ca106bfd487fdc39b58424fb57369 | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=100-167/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | check_line(o, line) | function | def check_line (o, line):
global last_seq
global json_obj
global test_id
if args.checkenc == 'json':
obj = json.loads(line)
else:
arr = line.split(',')
obj = {}
i = 0
for f in json_obj_fields:
obj[f] = arr[i]
i += 1
if not 'seq' i... |
1,153 | c48fe4008f65c1bfb150de1f71ebc933 | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=175-205/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | output_checker_main(o) | function | def output_checker_main (o):
global outputs_started
outputs_started += 1
log('opening output checker on ' + o['fifo'])
f = open(o['fifo'], 'r')
log('output checker opened fifo %s, sample-rate %d' % \
(o['fifo'], o['rate']))
o['last_seq'] = 0;
line = f.readline()
cnt = 0
... |
1,154 | f76d7dbf076e9f303e8a3c6463f73c52 | swh:1:cnt:ac2078ffd6d28b2d9569247639452ef74eef951d;origin=https://gerrit.wikimedia.org/r/analytics/kafkatee.git;lines=216-220/ | 356a51a22590a98ededa5b1ae3cea5f352ccdc9c | kafkatee | analytics | test/testpipe.py | sig_timeout(sig, frame) | function | def sig_timeout (sig, frame):
log('\033[31mFATAL: Test timed out\033[0m')
os.kill(os.getpid(), 9)
# NOTREACHED
fatal("Test timed out") |
1,155 | 255f0536f322aea54bfe607bd6ffbb76 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=33-695/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus | type | /**
* A "metric" that observes rdkafka statistics
*/
class RdkafkaPrometheus {
/**
* Create the collector
*
* @param {Object} options options for the collector
* @param {Object} options.prometheus
* prom-client. Pass this in directly from your application if your app
* requires pro... |
1,156 | 1215ac03086d78064f4e26a52feca361 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=37-462/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::constructor | function | /**
* Create the collector
*
* @param {Object} options options for the collector
* @param {Object} options.prometheus
* prom-client. Pass this in directly from your application if your app
* requires prom-client itself. prom-client won't work if it is required
* multiple times in ... |
1,157 | 96f9029650f9c8b8f34e2f805a4f0ef5 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=464-479/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdkafkaStat | function | _translateRdkafkaStat(key, value, labels, valueMapper = (v) => v) {
const metric = this.metrics[key.toUpperCase()];
if (metric) {
try {
const observe = 'observe' in metric ? 'observe' : 'set';
metric[observe](labels, valueMapper(value));
} catch (e... |
1,158 | 9d22b482dda456786c57f2ae81d8b7af | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=481-485/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdKafkaBrokerWindowStats | function | _translateRdKafkaBrokerWindowStats(windowKey, brokerWindowStats, brokerLabels) {
for (const key of Object.keys(brokerWindowStats)) {
this._translateRdkafkaStat(`broker_${windowKey}_${key}`, brokerWindowStats[key], brokerLabels);
}
} |
1,159 | 8ca8528adbd16816133d70468cebd75d | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=504-549/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdkafkaBrokerStats | function | _translateRdkafkaBrokerStats(brokerStats, globalLabels) {
const brokerLabels = Object.assign({}, globalLabels, {
name: brokerStats.name,
nodeid: brokerStats.nodeid
});
for (const key of Object.keys(brokerStats)) {
switch (key) {
case 'name':
... |
1,160 | 46080cd37ffc36a36ff3bcedcc223fc2 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=487-502/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdKafkaBrokerTopparsStats | function | _translateRdKafkaBrokerTopparsStats(brokerTopparsStats, brokerLabels) {
const brokerTopparsLabels = Object.assign({}, brokerLabels, {
topic: brokerTopparsStats.topic
});
for (const key of Object.keys(brokerTopparsStats)) {
switch (key) {
case 'topic':
... |
1,161 | abedcc444fc23d46af029f181d93de3c | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=551-600/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdkafkaTopicPartitionStats | function | _translateRdkafkaTopicPartitionStats(statKey, topicPartitionStats, topicLabels) {
const topicPartitionLabels = Object.assign({}, topicLabels, {
partition: topicPartitionStats.partition
});
for (const key of Object.keys(topicPartitionStats)) {
switch (key) {
ca... |
1,162 | 5b2cd48177a02f7281871f3bd2b55ee6 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=602-623/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdkafkaTopicStats | function | _translateRdkafkaTopicStats(topicStats, globalLabels) {
const topicLabels = Object.assign({}, globalLabels, {
topic: topicStats.topic
});
for (const key of Object.keys(topicStats)) {
switch (key) {
case 'topic':
// Ignore: Part of the topic lab... |
1,163 | 2a09ae5bd49516605d2ab6db83271aba | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=625-630/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdkafkaCgrpStats | function | _translateRdkafkaCgrpStats(cgrpStats, globalLabels) {
const cgrpLabels = Object.assign({}, globalLabels);
for (const key of Object.keys(cgrpStats)) {
this._translateRdkafkaStat(`cgrp_${key}`, cgrpStats[key], cgrpLabels);
}
} |
1,164 | 97224aa8c5adc357acd3a166daea4824 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=632-666/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::_translateRdkafkaPrometheus | function | _translateRdkafkaPrometheus(stats, extraLabels = {}) {
const globalLabels = Object.assign(
{},
this.extraLabels,
{
handle: stats.name,
type: stats.type
},
extraLabels
);
for (const key of Object.keys(stat... |
1,165 | 17622315d6d57fc7813962021dfb1a21 | swh:1:cnt:915c57cce168e49bafb865b10d3935609897ef76;origin=https://gitlab.wikimedia.org/repos/data-engineering/node-rdkafka-prometheus.git;lines=668-694/ | a5651ebd76c554b7aa85fecf6a19992f952f07e5 | node-rdkafka-prometheus | analytics | index.js | RdkafkaPrometheus::observe | function | /**
* "Observe" the given statistics
*
* This internally translates the statistics into many prometheus metrics.
*
* @param {Object} stats
* rdkafka raw statistics
* @param {Object} extraLabels
* keys must have already been declared when instantiating this RdkafkaPrometheus ins... |
1,166 | 468455c435434151046cbeae2ca9463a | swh:1:cnt:1349583a4014335ac6c44108e47178b731dd52d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=22-167/ | 56f95ef657cc006c6d6f7b599ceaf5d863429cd5 | eventstreams | analytics | app.js | initApp | function | /**
* service-utils functionality that is added to Express
*
* @typedef {Object} _ServiceUtils
* @property {winston.Logger} logger
* @property {ServiceUtils.metrics} metrics
* @property {Object} conf
* @property {Function} close
*/
/**
* Express app with service-utils functionality
*
* @typedef {express.Exp... |
1,167 | 647c6cb9324a89ae57e0b3fb464bb994 | swh:1:cnt:1349583a4014335ac6c44108e47178b731dd52d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=169-221/ | 56f95ef657cc006c6d6f7b599ceaf5d863429cd5 | eventstreams | analytics | app.js | loadRoutes | function | /**
* Loads all routes declared in routes/ into the app
*
* @param {Express.Application} app the application object to load routes into
* @param {string} dir routes folder
* @return {Promise<express.Express>} a promise resolving to the app object
*/
async function loadRoutes(app, dir) {
// recursively load r... |
1,168 | 6d1e2727c45d7baec2c6024fee64348b | swh:1:cnt:1349583a4014335ac6c44108e47178b731dd52d1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=223-253/ | 56f95ef657cc006c6d6f7b599ceaf5d863429cd5 | eventstreams | analytics | app.js | createServer | function | /**
* Creates and start the service's web server
*
* @param {ServiceUtilsExpress} app
* @return {http.Server} a promise creating the web server
*/
function createServer(app) {
// return a promise which creates an HTTP server,
// attaches the app to it, and starts accepting
// incoming client requests
... |
1,169 | 892f1a43be6e0645d636959ab3c4b784 | swh:1:cnt:a2f7a147b7c9e01c0b856814514006f0e126cf49;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=9-38/ | e0a119fd92be14685ba7d72ff45f173816b14ec6 | eventstreams | analytics | lib/eventstreams-util.js | deserializer | function | /**
* Custom message deserializer for eventstreams.
* Augments the deserialized message with kafka
* metadata in the .meta subobject.
*
* @param {Object} kafkaMessage
* @return {Object}
*/
function deserializer(kafkaMessage) {
kafkaMessage.message = objectFactory(kafkaMessage.value);
if (!kafkaMessage.m... |
1,170 | a454f4049ba9c661034e7b959948fe26 | swh:1:cnt:a2f7a147b7c9e01c0b856814514006f0e126cf49;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=40-51/ | e0a119fd92be14685ba7d72ff45f173816b14ec6 | eventstreams | analytics | lib/eventstreams-util.js | normalizePageTitle | function | /**
* Normalize a page title to a lowercase string with underscores.
*
* @param {string} pageTitle
* @return {string} Normalized page title
*/
function normalizePageTitle(pageTitle) {
if (pageTitle === null || pageTitle === undefined) {
return undefined;
}
return String(pageTitle).trim().replac... |
1,171 | bb75fe180bc53628498bbe1c46a95032 | swh:1:cnt:a2f7a147b7c9e01c0b856814514006f0e126cf49;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=53-126/ | e0a119fd92be14685ba7d72ff45f173816b14ec6 | eventstreams | analytics | lib/eventstreams-util.js | redactMessage | function | /**
* Redact message content based on deny list of page titles,
* populated with the full page name.
*
* @param {Object} message kafka message
* @param {Object} normalizedRedactedPages normalized redacted pages from config
* @param {Object} options options
* @return {Object} redacted message
*/
function redactM... |
1,172 | bb5b3e19ebeaa2cd52d167d8544f79cc | swh:1:cnt:a2f7a147b7c9e01c0b856814514006f0e126cf49;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=188-202/ | e0a119fd92be14685ba7d72ff45f173816b14ec6 | eventstreams | analytics | lib/eventstreams-util.js | makeDeserializer | function | /**
* Returns a deserializer factory function, applying MediaWiki page redaction if configured.
* This is necessary because KafkaSSE invokes the deserializer internally,
* so we cannot directly pass deserialization options from eventstreams;
* instead, we use currying to inject options when needed.
*
* @param {Ob... |
1,173 | 22f0deee8b292989f6e7ab655de8f813 | swh:1:cnt:a2f7a147b7c9e01c0b856814514006f0e126cf49;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=129-186/ | e0a119fd92be14685ba7d72ff45f173816b14ec6 | eventstreams | analytics | lib/eventstreams-util.js | makePartialMediaWikiRedactorDeserializer | function | /**
* Time sensitive, one off, implementation to support T354456.
*
* Redact message content based on deny list of page titles,
* populated with the full page name.
*
* TODO: re-evaluate this approach after integration testing.
*
* @param {{string: string[]}} redacted_pages Map of wiki to list of redacted pages... |
1,174 | 54a8216331ae3b849f2b7f33967309eb | swh:1:cnt:a2f7a147b7c9e01c0b856814514006f0e126cf49;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=252-254/ | e0a119fd92be14685ba7d72ff45f173816b14ec6 | eventstreams | analytics | lib/eventstreams-util.js | rdkafkaStatsFilter | function | function rdkafkaStatsFilter(key) {
return _.includes(rdkafkaStatsWhitelist, key);
} |
1,175 | d6a4b377f45eedba542b83ef755316d0 | swh:1:cnt:a262f48f73386cf0b2436d8a5c3af9958932ed4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=13-103/ | 4e41563ec51ae3e3669c2f3a132ba6b4a5ffd5b2 | eventstreams | analytics | lib/swagger-ui.js | processRequest | function | function processRequest(app, req, res) {
const reqPath = req.query.path || '/index.html';
const filePath = path.join(docRoot, reqPath);
// Disallow relative paths.
// Test relies on docRoot ending on a slash.
if (filePath.slice(0, docRoot.length) !== docRoot) {
throw new HTTPError({
... |
1,176 | de47caa5f8786a86c51272cf72968fec | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=4-31/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | HTTPError | type | /**
* Error instance wrapping HTTP error responses
*/
class HTTPError extends Error {
constructor(response) {
super();
Error.captureStackTrace(this, HTTPError);
if (response.constructor !== Object) {
// just assume this is just the error message
response = {
... |
1,177 | 8612c99bf546f959f2365750332041bc | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=9-30/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | HTTPError::constructor | function | constructor(response) {
super();
Error.captureStackTrace(this, HTTPError);
if (response.constructor !== Object) {
// just assume this is just the error message
response = {
status: 500,
type: 'internal_error',
title: 'Inter... |
1,178 | e963d528f7a9d710e0d3ece448580336 | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=65-88/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | errForLog | function | /**
* Serialises an error object in a form suitable for logging.
*
* @param {!Error} err error to serialise
* @return {!Object} the ecs formatted serialised version of the error
*/
function errForLog(err) {
const ret = {
message: err.message,
error: {
type: err.type,
sta... |
1,179 | 1952a52e7bdad1a1e7efc1cbc3b72009 | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=33-63/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | reqForLog | function | /**
* Generates an object suitable for logging out of a request object
*
* @param {!Request} req the request
* @param {?RegExp} whitelistRE the RegExp used to filter headers
* @return {!Object} an object containing the key components of the request
*/
function reqForLog(req, whitelistRE) {
const r... |
1,180 | d013121ea7f5c33fa151948bf5038ac9 | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=172-190/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | createRouter | function | /**
* Creates a new router with some default options.
*
* @param {?Object} [opts] additional options to pass to express.Router()
* @return {!Router} a new router object
*/
function createRouter(opts) {
const options = {
mergeParams: true
};
if (opts && opts.constructor === Object) {
O... |
1,181 | 2e3b658e1a1f7cca9ba890a20cf53e0a | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=90-170/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | setErrorHandler | function | /**
* Generates an error handler for the given applications and installs it.
*
* @param {!Application} app the application object to add the handler to
*/
function setErrorHandler(app) {
app.use((err, req, res, next) => {
let errObj;
// ensure this is an HTTPError object
if (err.constru... |
1,182 | 48ec050af16596eb9e286792aecf3869 | swh:1:cnt:5efef2e8c907bda7893d4b30717c585c2f29f06d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=192-241/ | eeb1161a11d65c15036462ddfaa69e22962c46fe | eventstreams | analytics | lib/util.js | initAndLogRequest | function | /**
* Adds logger to the request and logs it.
*
* @param {Express.Request} req request object
* @param {!Application} app application object
*/
function initAndLogRequest(req, app) {
req.headers = req.headers || {};
req.headers['x-request-id'] = req.headers['x-request-id'] || uuidv1();
req.logger = app... |
1,183 | 692cd088119835e19ef87440d64b3820 | swh:1:cnt:5b702d1318acae2992a2f89489e729c251b76236;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=28-193/ | 4e0955f9f4c4e6639e6905b351e19c3be7db6c02 | eventstreams | analytics | routes/stream.js | loadStreamConfigs | function | /**
* Loads stream configs from app.conf.stream_config_uri.
* Regex stream names are not supported and will be removed.
* Streams without a topics setting will be removed.
* If a stream_aliases setting is found for a stream, that stream
* config will be duplicated and also keyed by each stream alias.
*
* Some st... |
1,184 | 9b0a5bf80f6e0c42f85032728d8bb266 | swh:1:cnt:5b702d1318acae2992a2f89489e729c251b76236;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=195-256/ | 4e0955f9f4c4e6639e6905b351e19c3be7db6c02 | eventstreams | analytics | routes/stream.js | updateSpec | function | /**
* Updates the OpenAPI spec at app.conf.spec with path routes exposing
* the streams declared in streamConfigs.
*
* streamConfig.description will be used for the route path description.
* If streamConfig.schema is given, it will be
* used as the route path responses schema and example.
*
* @param {Object} ap... |
1,185 | 3b213a591745ef0ca9ca843985d00874 | swh:1:cnt:5b702d1318acae2992a2f89489e729c251b76236;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=438-459/ | 4e0955f9f4c4e6639e6905b351e19c3be7db6c02 | eventstreams | analytics | routes/stream.js | decrementConnectionCount | function | // After the connection is closed, decrement the number
// of current connections for these streams.
function decrementConnectionCount() {
// Only decrement once even if close and/or finish is called multiple times
if (connectionClosed) {
return;
}
... |
1,186 | 3f1ab4cf58e4a9571c7c0557a554b26f | swh:1:cnt:b1043f2ddd7288e0622c06537b99f39d0fa99b4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=14-52/ | 4c052e9ff5aa796c132ccb4eae74119ed7163c12 | eventstreams | analytics | scripts/gen-init-scripts.rb | ScriptData | type | class ScriptData
include ERB::Util
@@suffix = {'systemd' => '.service', 'upstart' => '.conf'}
def initialize input_dir
@template = {}
self.init input_dir
end
def set_info root_dir
self.read_info(root_dir).each do |key, value|
self.instance_variable_set "@#{key}".to_sym, value
end
... |
1,187 | 30468cf28bd9fdb7a675adf065d4d9f2 | swh:1:cnt:b1043f2ddd7288e0622c06537b99f39d0fa99b4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=20-23/ | 4c052e9ff5aa796c132ccb4eae74119ed7163c12 | eventstreams | analytics | scripts/gen-init-scripts.rb | ScriptData::initialize | function | def initialize input_dir
@template = {}
self.init input_dir
end |
1,188 | f2c0ed7478c67ce18f36fb2163c16665 | swh:1:cnt:b1043f2ddd7288e0622c06537b99f39d0fa99b4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=25-31/ | 4c052e9ff5aa796c132ccb4eae74119ed7163c12 | eventstreams | analytics | scripts/gen-init-scripts.rb | ScriptData::set_info | function | def set_info root_dir
self.read_info(root_dir).each do |key, value|
self.instance_variable_set "@#{key}".to_sym, value
end
@service_name = @name
@no_file ||= 10000
end |
1,189 | 8bf99f43149125bea5ff3480b64d0d6e | swh:1:cnt:b1043f2ddd7288e0622c06537b99f39d0fa99b4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=47-50/ | 4c052e9ff5aa796c132ccb4eae74119ed7163c12 | eventstreams | analytics | scripts/gen-init-scripts.rb | ScriptData::read_info | function | def read_info root_dir
data = yaml.load(File.read(File.join(root_dir, 'config.yaml')))['services'][0]['conf']
return data.merge(JSON.load(File.read(File.join(root_dir, 'package.json'))))
end |
1,190 | 8b6df07a7145987965b2fc157152429a | swh:1:cnt:b1043f2ddd7288e0622c06537b99f39d0fa99b4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=33-39/ | 4c052e9ff5aa796c132ccb4eae74119ed7163c12 | eventstreams | analytics | scripts/gen-init-scripts.rb | ScriptData::generate | function | def generate output_dir
@template.each do |name, erb|
File.open(File.join(output_dir, "#{@name}#{@@suffix[name]}"), 'w') do |io|
io.write erb.result(binding())
end
end
end |
1,191 | 14af431af3f7e1f3383c66cfd5a5fa13 | swh:1:cnt:b1043f2ddd7288e0622c06537b99f39d0fa99b4d;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=41-45/ | 4c052e9ff5aa796c132ccb4eae74119ed7163c12 | eventstreams | analytics | scripts/gen-init-scripts.rb | ScriptData::init | function | def init input_dir
Dir.glob(File.join(input_dir, '*.erb')).each do |fname|
@template[File.basename(fname, '.erb')] = ERB.new(File.read(fname))
end
end |
1,192 | dab262753eff62f15cdc19bb2de7232e | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=12-45/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | validateExamples | function | function validateExamples(pathStr, defParams, mSpec) {
const uri = new URI(pathStr, {}, true);
if (!mSpec) {
try {
uri.expand(defParams);
return true;
} catch (e) {
throw new Error(`Missing parameter for route ${pathStr} : ${e.message}`);
}
}
... |
1,193 | faa67716f1d30fb6cda84f797a8f3802 | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=166-191/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | validateArray | function | function validateArray(val, resVal, key) {
assert.deepEqual(Array.isArray(resVal), true, `Body field ${key} is not an array!`);
let arrVal;
if (val.length === 1) {
// special case: we have specified only one item in the expected body,
// but what we really want is to check all of the returne... |
1,194 | 1648d683064d5f281cf9df0648036d5b | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=67-108/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | constructTests | function | function constructTests(testSpec) {
const ret = [];
const paths = testSpec.paths;
const defParams = testSpec['x-default-params'] || {};
Object.keys(paths).forEach((pathStr) => {
Object.keys(paths[pathStr]).forEach((method) => {
const p = paths[pathStr][method];
// No-ops... |
1,195 | 57cb98277621de302da235cee1f3fb24 | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=110-164/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | cmp | function | function cmp(result, expected, errMsg) {
if (expected === null || expected === undefined) {
// nothing to expect, so we can return
return true;
}
if (result === null || result === undefined) {
result = '';
}
if (expected.constructor === Object) {
Object.keys(expecte... |
1,196 | 83292ee063cfffb47e2208700e5035f3 | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=47-65/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | constructTestCase | function | function constructTestCase(title, path, method, request, response) {
return {
title,
request: {
uri: (baseUrl || server.config.uri) + (path[0] === '/' ? path.slice(1) : path),
method,
headers: request.headers || {},
query: request.query,
bo... |
1,197 | 0e0c0cb93e9da69d37ab7d332e9e080f | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=193-226/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | validateBody | function | function validateBody(resBody, expBody) {
if (!expBody) { return true; } // eslint-disable-line
if (!resBody) { return false; } // eslint-disable-line
if (Buffer.isBuffer(resBody)) {
resBody = resBody.toString();
}
if (expBody.constructor !== resBody.constructor) {
if (expBody.const... |
1,198 | 4126581b67c0470222b0dea962691e2f | swh:1:cnt:626ba559e25be0d703eea401cdf52cee3a1ca150;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=228-248/ | cc7d0711752685f5fa2633f389e1199fd500e953 | eventstreams | analytics | test/features/app/spec.js | validateTestResponse | function | /**
*
* @param {Object} testCase
* @param {Response} res
* @return {void}
*/
function validateTestResponse(testCase, res) {
const expRes = testCase.response;
assert.deepEqual(res.status, expRes.status);
if (expRes.headers && !res.headers) {return false; } // eslint-disable-line
Object.keys(expRe... |
1,199 | 10870bfe9b1541592b6681ba698f9b31 | swh:1:cnt:3e6a29024b714b3e40459412e4eb22eea9fae7e1;origin=https://gitlab.wikimedia.org/repos/data-engineering/eventstreams.git;lines=25-37/ | 0b59ae770cc05f59e418dc38c3dd20bfbf8a44c7 | eventstreams | analytics | test/features/info/info.js | checkRet | function | // common function used for generating requests
// and checking their return values
async function checkRet(fieldName) {
const res = await fetch(infoUri + fieldName);
// check the returned Content-Type header
assert.contentType(res, 'application/json');
const body = await res.jso... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.