Was reading https://blog.appsignal.com/2019/12/12/how-to-use-broadway-in-your-elixir-application.html
and wanted to get a better understanding of how the incoming messages can be triggered and managed.
Right out the box with this tut, it uses a WorldTemp.CityProducer
example that I have a hard time understanding. There are two cases of handle_demand
, one is for when demand > length(state)
the other for when this is not true.
First: What does demand here represent? It starts with a default value of 10. Where does this value come from and what does it represent? What should I read to get a betting understanding of this value?
Second: The city list function is a static list. What if I wanted to do an ecto query and get a list of rows that should be processed. Is this where that request would look up said rows?
I guess so far the producer is the most confusing part to me.
Edit: I think I figured out my disconnect. This module is a GenStage. https://hexdocs.pm/gen_stage/GenStage.html?#c:handle_demand/2 and not directly related to Broadway.
Time to go learn some GenStage I guess.