Hey!
I created a simple project using GenStage
only to study more deeply how the processes comunicate with each other. Instead of using the default erlang tracer, I implemented a prettier tracer and also added some extra logging stuff, that help me understand better how the stages behave with different max_demand
and min_demand
configurations.
The Stages
[Stock] ----------> [Chef] ------------> [Checkout] >>>>>>>>> Checkout.Task
A example of the tracing logs
15:50.768 trace: :chef => :stock {:subscribe, nil, [min_demand: 3, max_demand: 5]}
15:50.768 trace: :chef => :stock {:ask, 5}
15:50.769 trace: :checkout => :chef {:subscribe, nil, [min_demand: 0, max_demand: 2]}
15:50.769 trace: :checkout => :chef {:ask, 2}
15:52.031 trace: :stock => :chef {:snt, 5}
15:53.037 trace: :chef => :checkout {:snt, 2}
15:53.038 trace: :chef => :stock {:ask, 2}
15:53.039 trace: :checkout => {:task, #PID<0.255.0>} :acai1029
15:53.039 trace: :checkout => {:task, #PID<0.256.0>} :acai1093
15:53.543 trace: :stock => :chef {:snt, 2}
15:54.039 trace: :checkout => :chef {:ask, 1}
...
Repository: https://github.com/HugoLnx/acai-restaurant
Hope it help.
PS.: I created a few issues with some ideas.