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.ex24
1 files changed, 23 insertions, 1 deletions
diff --git a/shard/lib/manager.ex b/shard/lib/manager.ex
index 57f2371..617378c 100644
--- a/shard/lib/manager.ex
+++ b/shard/lib/manager.ex
@@ -1,5 +1,17 @@
defprotocol Shard.Manifest do
- @doc "Start the corresponding Shard process"
+ @moduledoc"""
+ A shard manifest is a data structure that uniquely defines the identity of the shard.
+
+ The hash of the manifest is the unique identifier of that shard on the network.
+
+ The Manifest protocol is a protocol implemented by the manifest structs for the
+ different shard types. It contains an operation start() that is able to launch the
+ correct process for this shard and connect to other peers that use it.
+ """
+
+ @doc"""
+ Start the corresponding Shard process
+ """
def start(manifest)
end
@@ -261,6 +273,16 @@ defmodule Shard.Manager do
end
@doc"""
+ Returns the pid for a shard if it exists
+ """
+ def find_proc(shard_id) do
+ case :dets.lookup(@shard_db, shard_id) do
+ [{^shard_id, _, pid}] -> pid
+ _ -> nil
+ end
+ end
+
+ @doc"""
Register a process as the handler for shard packets for a given path.
"""
def dispatch_to(shard_id, path, pid) do