I'm developing my first medium/big application in elixir and I'm trying to get familiar with the common patterns in elixir system design and architectures.
At this moment I'm trying to implement an input queue (currently implemented using the erlang :queue), exposed through and API and I want to have consumers from that queue performing some processing and storing the data.
I have created the queue using an Agent and I have implemented a genStage that queries the queue for elements and a genstage consumer for performing all the processing that I need. In summary something like this
Queue Agent -------> GenStage producer ---------> GenStage consumer -----> database
My questions are the following:
After some comments and reading documentation I realised that
GenStage is based on
GenServer and I have the possibility to manage the internal state from outside the
After this I refactored the code and now I have the
:queue as part of the
GenStage state, so I don't need to polling any queue outside the
GenStage and I also have the possibility to add elements into the queue using the
Now I have the Queue working as a
GenStage producer and I have been able to connect my database service as a consumer