Samagra-Development / yaus

Yet Another URL Shortner
https://github.com/Samagra-Development/yaus/wiki
11 stars 28 forks source link

Integrate RMQ #74

Closed yuvrajsab closed 1 year ago

yuvrajsab commented 1 year ago

We need to follow the design doc HLD. So all the side-effects (task that can be done in the background) should occur at RabbitMQ so they won't add overhead to the endpoints. For example, we are tracking the click count in the redis but this operation could take some time and add overhead to the redirect endpoint. ref https://github.com/Samagra-Development/yaus/blob/master/apps/api/src/app/app.service.ts#L128-L130C1.

We need to identify at what other places we are doing this thing and refactor that.

Nazi-pikachu commented 1 year ago

After digging through this i can see that there is already a publisher to publish click events to RMQ and a consumer to consume those events and increment the click count in redis. But for some reason this functionality is currently commented out and instead click-counts are incremented directly as you pointed out. Pushing to queue: https://github.com/Samagra-Development/yaus/blob/3cade479eae5f68c5226cadfeb1647f438b0de11/apps/api/src/app/app.controller.ts#L77C4-L81C20 Consumer: https://github.com/Samagra-Development/yaus/blob/3cade479eae5f68c5226cadfeb1647f438b0de11/apps/api/src/app/app.controller.ts#L137C1-L147C3 MS siide effects : https://github.com/Samagra-Development/yaus/blob/3cade479eae5f68c5226cadfeb1647f438b0de11/apps/api/src/main.ts#L25C1-L35C9 Was there any specific reason to do this and if no then do we want to perform these task async through RMQ as per HLD ?

yuvrajsab commented 1 year ago

Is this done?

Nazi-pikachu commented 1 year ago

@yuvrajsab Yes this can be closed

yuvrajsab commented 1 year ago

closed via #83