Day 8: The beautiful GenStage
So, I finally grokked the GenStage abstraction! Yay!
GenStage has a lot of moving parts and is a bit difficult to understand because of all the ways in which it can be setup. My use case however, was very simple:
I wanted a worker pool and queue which would work in tandem. Like I discussed yesterday, Dropbox sends a webhook whenever a user changes their files. And, these changes need to be then parsed and synced properly. In my use case, all I needed was:
- A Queue: Which would accumulate user ids posted to our webhook endpoint.
- N Workers: Where each worker would ask the queue to give a single user id, and then sync that user.
In GenStage terms, I had a single producer(Queue) and multiple consumers(Worker). The blog post ended up with a lot of code, you can check it out at: http://blog.12startupsin12months.in/2017/06/22/day-8-the-beautiful-gen_stage/