elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.54k stars 3.38k forks source link

(Soft) deprecate Supervisor.Spec.supervise #5261

Closed josevalim closed 8 years ago

josevalim commented 8 years ago

The goal is to return those options as part of the :ok tuple. Instead of:

def init(arg) do
  children = [
    ...
  ]
  supervise(children, strategy: :one_for_one)
end

we should return:

def init(arg) do
  children = [
    ...
  ]
  {:ok, children, strategy: :one_for_one}
end

The rationale is to use regular data types and avoid centralizing all options in the supervise definition. This is particularly important when we include the DynamicSupervisor, which will have options specific only to itself.

The tuple format is already being used by GenStage as well as the DynamicSupervisor.

/cc @fishcakez

fishcakez commented 8 years ago

If we are going to use data types should we switch to the format used by :supervisor from OTP 18+ that uses maps?

josevalim commented 8 years ago

@fishcakez returning a map for optional keys is very foreign in Elixir, as well as the {:ok, {opts, children}} format. Plus OTP uses different defaults than Elixir, which means we would have different behaviour anyway.

fishcakez commented 8 years ago

If we use our own data format wont we lose the ability to appup top level supervisors?

fishcakez commented 8 years ago

To add context to my above comment. The module of the top level supervisor is discovered using format_status/2. This is controlled by :supervisor. To use our own data structures we would have to wrap use modules and that would mean :supervisor would always point to the wrapper module. Therefore preventing discovery of the top level supervisor's module and so it could not be reconfigured as part of an appup.

josevalim commented 8 years ago

We can't do this one. So I will open up an issue to merge DynamicSupervisor and we will need to revisit the DynamicSupervisor init return by then.