Gen_stage app design question

Hello, I’m coding a gen_stage app that should run several producers, producer_condumers and consumers at the same time, and after reading everything I could find about gen_stage it’s quite clear how things should work together (and wow, it’s beautiful!).
Now, with most of those components already built and running, I still can’t figure out where I should initialize, configure and especially subscribe?
For example, I have a producer feeding a producer_consumer that should initialize several other “instances” of the first producer after performing some operations, I figured out the single bits but I’m still missing the general picture.
How I imagine it to be:
A -> B -> A -> B
and so on until B doesn’t stop.
How should I build this? Like https://github.com/elixir-lang/gen_stage/blob/master/examples/consumer_supervisor.exs ?
Because I suppose I should at some point just have a function that takes what the producer_consumer produces and just start all the producers checking some condition on the data, but definitely not sure where to put that.

Thanks in advance

1 Like