tajul-saajan / google-searcher

0 stars 0 forks source link

[Chore] Brittle asynchronous processing of keywords #8

Open olivierobert opened 1 year ago

olivierobert commented 1 year ago

Issue

Upon uploading keywords, the scraping will be performed asynchronously via an event listener

https://github.com/tajul-saajan/google-searcher/blob/36a95d4f0ee6216e9fb4abdb15038b12d2f25d54/src/search/listeners/search.listener.ts#L17-L27

All keywords are processed in a loop. If any error occurs in the loop, the latter will stop, and all remaining keywords will not be scraped and will not even have been saved to the database. A queue (supported by Nest.JS, see: https://docs.nestjs.com/techniques/queues) would be a better fit in this case.

[!WARNING] Using the observer pattern can be beneficial when there is more than one subscriber/consumer. Since the event is consumed in the same module as it is emitted, it creates indirection unnecessarily.

Expected

The benefits are: