Streamlined child specs

Elixir 1.5 introduced streamlined child specs, which allow the child specifications to be defined in modules. Instead of relying on the worker and supervisor functions from the Supervisor.Spec module, supervisors now receive a list of modules as children, and will call the child_spec/1 function on each child module. This allows the child module to control how they are run under a supervisor.

Let's see the modules presented in the previous example now using streamlined child specs. In the supervisor, we only changed the init/1 function to the following:

$ cat examples/upload_pipeline_supervisor_with_streamlined_child_specs.exdefmodule ElixirDrip.Storage.Supervisors.Upload.Pipeline do  # ...  def init(:ok) do Logger.debug("#{inspect(self())} ...

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.