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

Simpler pipeline producers

For the producer stage, we are currently passing the name and type via the start_link/2 function:

$ cat apps/elixir_drip/lib/elixir_drip/storage/pipeline/starter.exdefmodule ElixirDrip.Storage.Pipeline.Starter do  use GenStage  require Logger  alias ElixirDrip.Storage.Workers.QueueWorker  @queue_polling 5000  def start_link(name, type) do    GenStage.start_link(__MODULE__, type, name: name)  end  def init(type) do    Logger.debug("#{inspect(self())}: #{type} Pipeline Starter     started.")    {      :producer,      %{queue: QueueWorker.queue_name(type), type: type, pending: 0}    }  end  # ...end

We can see a pattern here: the name argument is only used by the start_link/2 function to set the producer process name when we start it, whereas the ...

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