From 3e085a063cbc968cca1fac6776bdc60f058ac23e Mon Sep 17 00:00:00 2001 From: Mohamed Asaker Date: Mon, 29 Jan 2024 13:29:11 -0800 Subject: [PATCH] update the throttle --- .../random-traffic-generator/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js index a01fa32e3..7a7507119 100644 --- a/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js +++ b/sample-applications/vehicle-dealership-sample-app/random-traffic-generator/index.js @@ -32,6 +32,11 @@ const postGetCarsTrafficTask = cron.schedule('* * * * *', async () => { .catch(err => { console.error(`${err.response}, ${err.response.data}`); }); // Catch and log errors + + axios.get(`http://${vehicleURL}/1`, { timeout: 10000 }) + .catch(err => { + console.error(err.response && err.response.data); + }); // Catch and log errors }, { scheduled: false }); postGetCarsTrafficTask.start(); @@ -63,7 +68,7 @@ const getCarThrottle = cron.schedule('*/5 * * * *', async () => { await sleep(sleepSecs*1000); throttleSecs = getRandomNumber(5,20); console.log(`request will be throttled for ${throttleSecs} seconds`) - axios.get(`http://${vehicleURL}/1`, {params: {"throttle": 5}}, { timeout: 10000 }) + axios.get(`http://${vehicleURL}/1`, {params: {"throttle": throttleSecs}}, { timeout: 10000 }) .catch(err => { console.error(err.response && err.response.data); }); // Catch and log errors