July 2018
Intermediate to advanced
574 pages
14h 7m
English
We've finally reached the first stage of this upload pipeline walk-through. As an event producer, our Starter stage will implement the handle_demand/2 callback instead of the handle_events/3 we've implemented so far for our Consumer and ProducerConsumer stages. This will also be the only stage that will keep state. As a Producer stage, the Starter stage needs to know at all times the queue from which it fetches new upload tasks and the outstanding demand it received and it has not yet fulfilled. Accordingly, its init/1 callback will return a {:producer, state} tuple where the state contains the queue, the type of events this Starter stage will create, and the pending demand.