Producer stage

Given we are creating the pipeline worker specs, we need to import the Supervisor.Spec module so that we can use the Supervisor.Spec.worker/3 function.

Since GenStage producers don't subscribe to any stage, we just need to create as many worker specs as the count option indicates. We concatenate the generated random name to the optional arguments to ensure that this name is passed when the start_link function is called during the producer process initialization. In the end, we return a tuple with two lists (created by unzipping the {name, worker_spec} tuples), one with the producer worker names, and the other with the corresponding worker specs:

$ cat apps/elixir_drip/lib/elixir_drip/dsl/pipeliner.exdefmodule ElixirDrip.Pipeliner ...

Get Mastering Elixir now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.