From bdfd58f468ed298dd70eefec443b77bda72d8ff5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Mart=C3=ADn?= Date: Thu, 15 Mar 2018 11:26:29 +0100 Subject: [PATCH] removing basic redis cell tests file --- redis-cell-test.js | 70 ---------------------------------------------- 1 file changed, 70 deletions(-) delete mode 100644 redis-cell-test.js diff --git a/redis-cell-test.js b/redis-cell-test.js deleted file mode 100644 index 5082fa16..00000000 --- a/redis-cell-test.js +++ /dev/null @@ -1,70 +0,0 @@ -const firstDuration = 4000; -const firstDelay = 250; -const secondDuration = 4000; -const secondDelay = 250; - - -const redis = require('redis'); -redis.add_command('CL.THROTTLE'); -const client = redis.createClient(); - -client.on("error", function (err) { - console.log("Error " + err); -}); - - -const stats = { - requests: 0, - success: 0, - limited: 0, - maxBurst: 2, - count: 2, - period: 1 -}; - -function doIt(cb) { - client['CL.THROTTLE']('key12345', stats.maxBurst, stats.count, stats.period, (err, data) => { - cb({ - limited: data[0], - limit: data[1], - remaining: data[2], - retry: data[3], - reset: data[4] - }); - }); -} - -function run(callsDelay, totalTime) { - let interval = setInterval( - function() { - doIt( ({limited, limit, remaining, retry, reset}) => { - - stats.requests++; - limited ? stats.limited++ : stats.success++; - - log(stats.requests, limited, limit, remaining, retry, reset); - }); - }, - callsDelay - ); - - setTimeout(() => { - clearInterval(interval); - console.log(stats); - - console.log("Max expected success", (totalTime / (stats.period * 1000) * stats.count) + stats.count + stats.maxBurst); - }, - totalTime); -} - -function log(request, limited, limit, remaining, retry, reset) { - let currentTime = new Date().getTime() - initTime; - console.log("\t" + request, "\t" + currentTime, "\t" + limited, "\t" + limit, "\t" + remaining, "\t" + retry, "\t" + reset); -} - -const initTime = new Date().getTime(); - -run(firstDelay, firstDuration); -setTimeout(() => { - run(secondDelay, secondDuration); -}, firstDuration + 2000); \ No newline at end of file