aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/manager.ex
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/manager.ex')
-rw-r--r--shard/lib/manager.ex16
1 files changed, 16 insertions, 0 deletions
diff --git a/shard/lib/manager.ex b/shard/lib/manager.ex
index 9def229..d6b493b 100644
--- a/shard/lib/manager.ex
+++ b/shard/lib/manager.ex
@@ -213,6 +213,22 @@ defmodule Shard.Manager do
end
@doc"""
+ Returns the pid for a shard defined by its manifest.
+ Start it if it doesn't exist.
+ """
+ def find_or_start(manifest) do
+ id = SData.term_hash manifest
+ case find_proc id do
+ nil ->
+ case Shard.Manifest.start manifest do
+ {:ok, pid} -> pid
+ {:error, :redundant} -> find_proc id
+ end
+ pid -> pid
+ end
+ end
+
+ @doc"""
Return the list of all shards.
"""
def list_shards() do