Use :simple_one_to_one to start dynamical supervisors

Henry H. Source

Is it possible in Elixir to start supervisors dynamically using :simple_one_to_one strategy, using Supervisor.start_child, or it's limited for GenServer workers ? If yes, let me ask you an example, many thanks.

elixir

Answers

answered 2 years ago tkowal #1

It is possible. Supervisors don't care if their children are workers or other supervisors. There is an example of using :simple_one_for_one strategy on the elixir lang page.

The only difference is that in the child specification instead of:

worker(KV.Bucket, [], restart: :temporary)

You would use something like:

supervisor(KV.Bucket.Supervisor, [])

comments powered by Disqus