aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/manager.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-09-26 14:37:10 +0200
committerAlex Auvolat <alex@adnab.me>2018-09-26 14:44:29 +0200
commitf16973d3a492ae6d4890c40d77b0a93d3293bf3a (patch)
tree36a38ec318ed9d0f87d28d508169271729b8507a /shard/lib/manager.ex
parent1df3aa74a6870f276bead1ed5650f0d86355ce09 (diff)
downloadshard-f16973d3a492ae6d4890c40d77b0a93d3293bf3a.tar.gz
shard-f16973d3a492ae6d4890c40d77b0a93d3293bf3a.zip
Signing and stuff
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