From 9707dd9498e83eb2b35e4199e815779d3570e1e1 Mon Sep 17 00:00:00 2001 From: DualFroz Date: Mon, 24 Aug 2026 11:17:00 +0200 Subject: [PATCH] feat(store): add shard supervisor --- lib/excache/store/supervisor.ex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lib/excache/store/supervisor.ex diff --git a/lib/excache/store/supervisor.ex b/lib/excache/store/supervisor.ex new file mode 100644 index 0000000..8688bdd --- /dev/null +++ b/lib/excache/store/supervisor.ex @@ -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