aboutsummaryrefslogtreecommitdiff
path: root/shard/lib/app/directory.ex
diff options
context:
space:
mode:
Diffstat (limited to 'shard/lib/app/directory.ex')
-rw-r--r--shard/lib/app/directory.ex21
1 files changed, 15 insertions, 6 deletions
diff --git a/shard/lib/app/directory.ex b/shard/lib/app/directory.ex
index cbea8c3..257e8b9 100644
--- a/shard/lib/app/directory.ex
+++ b/shard/lib/app/directory.ex
@@ -29,9 +29,18 @@ defmodule SApp.Directory do
end
defmodule State do
+ @moduledoc"""
+ Internal state struct of directory shard.
+ """
+
defstruct [:owner, :public, :name, :manifest, :id, :netgroup, :items, :revitems]
end
+ @doc"""
+ Start a process that connects to a given channel. Don't call directly, use for instance:
+
+ Shard.Manager.find_or_start %SApp.Directory.Manifest{owner: my_pk, public: false, name: "collection"}
+ """
def start_link(manifest) do
GenServer.start_link(__MODULE__, manifest)
end
@@ -217,23 +226,23 @@ defmodule SApp.Directory do
@doc"""
Return list of items stored in this directory.
- Returns a dictionnary of %{name => {manifest, stored?}}.
+ Returns a dictionnary of `%{name => {manifest, stored?}}`.
"""
def get_items(pid) do
GenServer.call(pid, :get_items)
end
@doc"""
- Return the manifest of item with a given name in directory, or nil if not found.
+ Return the manifest of item with a given name in directory, or `nil` if not found.
- Equivalent to get_items(pid)[name] but better.
+ Equivalent to `get_items(pid)[name]` but better.
"""
def read(pid, name) do
GenServer.call(pid, {:read, name})
end
@doc"""
- Find an item in the directory by its manifest. Returns name if found or nil if not found.
+ Find an item in the directory by its manifest. Returns name if found or `nil` if not found.
"""
def find(pid, manifest) do
GenServer.call(pid, {:find, manifest})
@@ -241,8 +250,8 @@ defmodule SApp.Directory do
@doc"""
Add an item to this directory. An item is a name for a shard manifest.
- An item added to a directory becomes a dependency of the directory, i.e.
- if the directory is pinned then all items inside are pinned as well.
+ An item added to a directory with `stored = true` becomes a dependency of the directory,
+ i.e. if the directory is pinned then all items inside are pinned as well.
"""
def add_item(pid, name, manifest, stored \\ true) do
GenServer.call(pid, {:add_item, name, manifest, stored})