You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -311,7 +311,7 @@ Let's change the registry to work with the buckets supervisor by rewriting how b
311
311
ifMap.has_key?(names, name) do
312
312
{:noreply, {names, refs}}
313
313
else
314
-
{:ok, pid} =KV.Bucket.Supervisor.start_bucket()
314
+
{:ok, pid} =KV.Bucket.Supervisor.start_bucket
315
315
ref =Process.monitor(pid)
316
316
refs =Map.put(refs, ref, name)
317
317
names =Map.put(names, name, pid)
@@ -343,7 +343,7 @@ This time we have added a supervisor as child, starting it with no arguments. Re
343
343
344
344
Since we have added more children to the supervisor, it is also important to evaluate if the `:one_for_one` strategy is still correct. One flaw that shows up right away is the relationship between registry and buckets supervisor. If the registry dies, the buckets supervisor must die too, because once the registry dies all information linking the bucket name to the bucket process is lost. If the buckets supervisor is kept alive, it would be impossible to reach those buckets.
345
345
346
-
We should consider moving to another supervision strategy like `:one_for_all` or `:rest_for_one`. The `:one_for_all` strategy kills and restarts all children whenever one of the children die. This would suit our case but may be too harsh as there is no need to crash the registry once the bucket supervisor dies since the registry supervises every bucket and would be able to clean itself up. That's when the `:rest_for_one` strategy is handy: `:rest_for_one` will only restart the crashed process along side the rest of tree. Let's rewrite our supervision tree to use it:
346
+
We should consider moving to another supervision strategy like `:one_for_all` or `:rest_for_one`. The `:one_for_all` strategy kills and restarts all children whenever one of the children die. This would suit our case but may be too harsh as there is no need to crash the registry once the bucket supervisor dies since the registry supervises every bucket and would be able to clean itself up. That's when the `:rest_for_one` strategy is handy: `:rest_for_one` will only restart the crashed process along side the rest of the tree. Let's rewrite our supervision tree to use it:
0 commit comments