Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

The Starter stage

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.

The call to QueueWorker.queue_name/1 with :upload ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content