diff options
author | Alex Auvolat <alex@adnab.me> | 2018-10-12 11:10:17 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2018-10-12 11:10:17 +0200 |
commit | d15d5fbfc5133a9d0f0d99dbbfc023849f61cc37 (patch) | |
tree | daedfd26af6978301b2633a338a137a874876d1f /shard/lib/manager.ex | |
parent | 6dcc2eefc3c8db0cadd7300536527dbd1905fa48 (diff) | |
download | shard-d15d5fbfc5133a9d0f0d99dbbfc023849f61cc37.tar.gz shard-d15d5fbfc5133a9d0f0d99dbbfc023849f61cc37.zip |
Update TODO, refactor a bit
Diffstat (limited to 'shard/lib/manager.ex')
-rw-r--r-- | shard/lib/manager.ex | 16 |
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 |