Skip to content

Commit

Permalink
update the throttle
Browse files Browse the repository at this point in the history
  • Loading branch information
AsakerMohd committed Jan 29, 2024
1 parent c776820 commit 3e085a0
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 3e085a0

Please sign in to comment.