aboutsummaryrefslogtreecommitdiff
path: root/lib/cli/cli.ex
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2018-07-19 17:08:23 +0200
committerAlex Auvolat <alex@adnab.me>2018-07-19 17:08:23 +0200
commit058bab0d7097405126566360308ace986c18ff8e (patch)
treeeaf3ca0d607829af3ad07bdb51bb170b70f8eef5 /lib/cli/cli.ex
parent582f1d65463f8f5cbcc34c6129670b473793c4dd (diff)
downloadshard-058bab0d7097405126566360308ace986c18ff8e.tar.gz
shard-058bab0d7097405126566360308ace986c18ff8e.zip
Refactoring ; template for block store
Diffstat (limited to 'lib/cli/cli.ex')
-rw-r--r--lib/cli/cli.ex13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/cli/cli.ex b/lib/cli/cli.ex
index d2e5f6a..3f83cb1 100644
--- a/lib/cli/cli.ex
+++ b/lib/cli/cli.ex
@@ -33,24 +33,23 @@ defmodule SCLI do
defp handle_command(pid, ["connect", ipstr, portstr]) do
{:ok, ip} = :inet.parse_address (to_charlist ipstr)
{port, _} = Integer.parse portstr
- SNet.Manager.add_peer(ip, port)
+ Shard.Manager.add_peer(ip, port)
pid
end
defp handle_command(pid, ["list"]) do
IO.puts "List of known channels:"
- list = GenServer.call(Shard.Manager, :list)
- for {_chid, chpid} <- list do
- {:chat, chan} = GenServer.call(chpid, :manifest)
+
+ for {_chid, manifest, _chpid} <- :ets.tab2list(:shard_db) do
+ {:chat, chan} = manifest
IO.puts "##{chan}"
end
pid
end
defp handle_command(pid, ["join", qchan]) do
- list = GenServer.call(Shard.Manager, :list)
- list = for {_chid, chpid} <- list,
- {:chat, chan} = GenServer.call(chpid, :manifest),
+ list = for {_chid, manifest, chpid} <- :ets.tab2list(:shard_db),
+ {:chat, chan} = manifest,
do: {chan, chpid}
case List.keyfind(list, qchan, 0) do
nil ->