summaryrefslogtreecommitdiff
path: root/worker.js
diff options
context:
space:
mode:
Diffstat (limited to 'worker.js')
-rw-r--r--worker.js10
1 files changed, 9 insertions, 1 deletions
diff --git a/worker.js b/worker.js
index a1c99a5..691e57b 100644
--- a/worker.js
+++ b/worker.js
@@ -29,7 +29,9 @@ const RABBITMQ_URI = process.env.RABBITMQ_URI,
BATCHSIZE = parseInt(process.env.BATCHSIZE) || 1000,
LOAD_TIMEOUT = parseInt(process.env.LOAD_TIMEOUT) || 5, // s
// wait time before next batch
- SLOWMODE = parseFloat(process.env.SLOWMODE) || 0; // s
+ SLOWMODE = parseFloat(process.env.SLOWMODE) || 0, // s
+ // chance that a message will be taken into account for statistics (drops others for performance)
+ RELIABILITY = parseFloat(process.env.RELIABILITY) || 1.0;
const logger = new (winston.Logger)({
transports: [
@@ -130,6 +132,12 @@ amqp.connect(RABBITMQ_URI).then(async (rabbit) => {
return;
}
+ if (RELIABILITY < 1.0 && Math.random() > RELIABILITY) {
+ // randomly drop some data :)
+ await ch.nack(msg, false, false);
+ return;
+ }
+
participants.add(msg.content.toString());
buffer.add(msg);
if (timeout == undefined) timeout = setTimeout(tryCrunch, LOAD_TIMEOUT*1000);