feat(store): add shard supervisor
This commit is contained in:
1 parent
381494514e
commit
9707dd9498
1 file changed
+21
@@ -0,0 +1,21 @@
|
|||||||
|
defmodule Excache.Store.Supervisor do
|
||||||
|
@moduledoc false
|
||||||
|
|
||||||
|
use Supervisor
|
||||||
|
|
||||||
|
def start_link(_arg) do
|
||||||
|
Supervisor.start_link(__MODULE__, :ok, name: __MODULE__)
|
||||||
|
end
|
||||||
|
|
||||||
|
@impl true
|
||||||
|
def init(:ok) do
|
||||||
|
count = Excache.Store.shard_count()
|
||||||
|
|
||||||
|
children =
|
||||||
|
for index <- 0..(count - 1) do
|
||||||
|
Supervisor.child_spec({Excache.Store.Shard, {index, count}}, id: {:shard, index})
|
||||||
|
end
|
||||||
|
|
||||||
|
Supervisor.init(children, strategy: :one_for_one)
|
||||||
|
end
|
||||||
|
end
|
||||||
Reference in new issue
Block a user