From 63138e71468e90bcf6af7d777e80d72c9c149a7d Mon Sep 17 00:00:00 2001 From: Christopher Date: Mon, 17 Feb 2020 20:31:52 -0600 Subject: [PATCH] more specs to the roles --- lib/wampex/roles/callee.ex | 5 +++++ lib/wampex/roles/caller.ex | 3 +++ lib/wampex/roles/peer.ex | 2 ++ lib/wampex/roles/publisher.ex | 3 +++ lib/wampex/roles/subscriber.ex | 2 ++ mix.exs | 1 + mix.lock | 4 ++++ 7 files changed, 20 insertions(+) diff --git a/lib/wampex/roles/callee.ex b/lib/wampex/roles/callee.ex index bb4ee5e..2152e14 100644 --- a/lib/wampex/roles/callee.ex +++ b/lib/wampex/roles/callee.ex @@ -18,22 +18,27 @@ defmodule Wampex.Role.Callee do Map.put(roles, :callee, %{}) end + @spec register(binary()) :: Wampex.message() def register(procedure) do [@register, %{}, procedure] end + @spec unregister(integer()) :: Wampex.message() def unregister(id) do [@unregister, id] end + @spec yield(integer()) :: Wampex.message() def yield(request_id) do [@yield, request_id, %{}] end + @spec yield(integer(), nonempty_list(any())) :: Wampex.message() def yield(request_id, arg_l) do [@yield, request_id, %{}, arg_l] end + @spec yield(integer(), nonempty_list(any()), map()) :: Wampex.message() def yield(request_id, arg_l, arg_kw) do [@yield, request_id, %{}, arg_l, arg_kw] end diff --git a/lib/wampex/roles/caller.ex b/lib/wampex/roles/caller.ex index e9ab1d6..e8d65cc 100644 --- a/lib/wampex/roles/caller.ex +++ b/lib/wampex/roles/caller.ex @@ -14,14 +14,17 @@ defmodule Wampex.Role.Caller do Map.put(roles, :caller, %{}) end + @spec call(binary()) :: Wampex.message() def call(procedure) do [@call, %{}, procedure] end + @spec call(binary(), nonempty_list(any())) :: Wampex.message() def call(procedure, arg_l) do [@call, %{}, procedure, arg_l] end + @spec call(binary(), nonempty_list(any()), map()) :: Wampex.message() def call(procedure, arg_l, arg_kw) do [@call, %{}, procedure, arg_l, arg_kw] end diff --git a/lib/wampex/roles/peer.ex b/lib/wampex/roles/peer.ex index a2109bc..9622fbd 100644 --- a/lib/wampex/roles/peer.ex +++ b/lib/wampex/roles/peer.ex @@ -17,10 +17,12 @@ defmodule Wampex.Role.Peer do @impl true def add(roles), do: roles + @spec hello(binary(), nonempty_list(module())) :: Wampex.message() def hello(realm, roles) do [@hello, realm, %{roles: Enum.reduce(roles, %{}, fn r, acc -> r.add(acc) end)}] end + @spec goodbye(binary()) :: Wampex.message() def goodbye(reason) do [@goodbye, %{}, reason] end diff --git a/lib/wampex/roles/publisher.ex b/lib/wampex/roles/publisher.ex index 69ada8c..614a0a1 100644 --- a/lib/wampex/roles/publisher.ex +++ b/lib/wampex/roles/publisher.ex @@ -14,14 +14,17 @@ defmodule Wampex.Role.Publisher do Map.put(roles, :publisher, %{}) end + @spec publish(binary()) :: Wampex.message() def publish(topic) do [@publish, %{}, topic] end + @spec publish(binary(), nonempty_list(any())) :: Wampex.message() def publish(topic, arg_l) do [@publish, %{}, topic, arg_l] end + @spec publish(binary(), nonempty_list(any()), map()) :: Wampex.message() def publish(topic, arg_l, arg_kw) do [@publish, %{}, topic, arg_l, arg_kw] end diff --git a/lib/wampex/roles/subscriber.ex b/lib/wampex/roles/subscriber.ex index c68296e..a34e02d 100644 --- a/lib/wampex/roles/subscriber.ex +++ b/lib/wampex/roles/subscriber.ex @@ -17,10 +17,12 @@ defmodule Wampex.Role.Subscriber do Map.put(roles, :subscriber, %{}) end + @spec subscribe(binary()) :: Wampex.message() def subscribe(topic) do [@subscribe, %{}, topic] end + @spec unsubscribe(integer()) :: Wampex.message() def unsubscribe(sub_id) do [@unsubscribe, sub_id] end diff --git a/mix.exs b/mix.exs index f682911..5b92a55 100644 --- a/mix.exs +++ b/mix.exs @@ -35,6 +35,7 @@ defmodule Wampex.MixProject do {:excoveralls, "~> 0.12.2", only: [:dev, :test], runtime: false}, {:credo, "~> 1.2", only: [:dev, :test], runtime: false}, {:dialyxir, "~> 0.5.1", only: [:dev, :test], runtime: false}, + {:ex_doc, "~> 0.21", only: :dev, runtime: false}, {:jason, "~> 1.1"}, {:msgpack, "~> 0.7.0"}, {:states_language, "~> 0.2"}, diff --git a/mix.lock b/mix.lock index 2c2f523..16d1737 100644 --- a/mix.lock +++ b/mix.lock @@ -5,13 +5,17 @@ "coveralls": {:hex, :coveralls, "2.1.0", "b44cea21202c0e1994dfced8cedbff66bcd03eeeb565484345b28afacda0559b", [:rebar3], [{:jsx, "2.10.0", [hex: :jsx, repo: "hexpm", optional: false]}], "hexpm", "bbfbe2a7bebb2d22db15a657e6c1733243e1501714d60fe14a14790d96e7c3b2"}, "credo": {:hex, :credo, "1.2.2", "f57faf60e0a12b0ba9fd4bad07966057fde162b33496c509b95b027993494aab", [:mix], [{:bunt, "~> 0.2.0", [hex: :bunt, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "8f2623cd8c895a6f4a55ef10f3fdf6a55a9ca7bef09676bd835551687bf8a740"}, "dialyxir": {:hex, :dialyxir, "0.5.1", "b331b091720fd93e878137add264bac4f644e1ddae07a70bf7062c7862c4b952", [:mix], [], "hexpm", "6c32a70ed5d452c6650916555b1f96c79af5fc4bf286997f8b15f213de786f73"}, + "earmark": {:hex, :earmark, "1.4.3", "364ca2e9710f6bff494117dbbd53880d84bebb692dafc3a78eb50aa3183f2bfd", [:mix], [], "hexpm", "8cf8a291ebf1c7b9539e3cddb19e9cef066c2441b1640f13c34c1d3cfc825fec"}, "elixpath": {:hex, :elixpath, "0.1.0", "f860e931db7bda6856dc68145694ca429643cc068ef30d7ff6b4096d4357963e", [:mix], [{:nimble_parsec, "~> 0.5", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "30ce06079b41f1f5216ea2cd11605cfe4c82239628555cb3fde9f10055a6eb67"}, + "ex_doc": {:hex, :ex_doc, "0.21.3", "857ec876b35a587c5d9148a2512e952e24c24345552259464b98bfbb883c7b42", [:mix], [{:earmark, "~> 1.4", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.14", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm", "0db1ee8d1547ab4877c5b5dffc6604ef9454e189928d5ba8967d4a58a801f161"}, "excoveralls": {:hex, :excoveralls, "0.12.2", "a513defac45c59e310ac42fcf2b8ae96f1f85746410f30b1ff2b710a4b6cd44b", [:mix], [{:hackney, "~> 1.0", [hex: :hackney, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "151c476331d49b45601ffc45f43cb3a8beb396b02a34e3777fea0ad34ae57d89"}, "hackney": {:hex, :hackney, "1.15.2", "07e33c794f8f8964ee86cebec1a8ed88db5070e52e904b8f12209773c1036085", [:rebar3], [{:certifi, "2.5.1", [hex: :certifi, repo: "hexpm", optional: false]}, {:idna, "6.0.0", [hex: :idna, repo: "hexpm", optional: false]}, {:metrics, "1.0.1", [hex: :metrics, repo: "hexpm", optional: false]}, {:mimerl, "~>1.1", [hex: :mimerl, repo: "hexpm", optional: false]}, {:ssl_verify_fun, "1.1.5", [hex: :ssl_verify_fun, repo: "hexpm", optional: false]}], "hexpm", "e0100f8ef7d1124222c11ad362c857d3df7cb5f4204054f9f0f4a728666591fc"}, "idna": {:hex, :idna, "6.0.0", "689c46cbcdf3524c44d5f3dde8001f364cd7608a99556d8fbd8239a5798d4c10", [:rebar3], [{:unicode_util_compat, "0.4.1", [hex: :unicode_util_compat, repo: "hexpm", optional: false]}], "hexpm", "4bdd305eb64e18b0273864920695cb18d7a2021f31a11b9c5fbcd9a253f936e2"}, "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "fdf843bca858203ae1de16da2ee206f53416bbda5dc8c9e78f43243de4bc3afe"}, "json_xema": {:hex, :json_xema, "0.4.0", "377446cd5c0e2cbba52b9d7ab67c05579e6d4a788335220215a8870eac821996", [:mix], [{:conv_case, "~> 0.2", [hex: :conv_case, repo: "hexpm", optional: false]}, {:xema, "~> 0.11", [hex: :xema, repo: "hexpm", optional: false]}], "hexpm", "452724a5b2751cd69191edd3fd3da0c2194c164ebd49efd85f9abb64d6621b53"}, "jsx": {:hex, :jsx, "2.10.0", "77760560d6ac2b8c51fd4c980e9e19b784016aa70be354ce746472c33beb0b1c", [:rebar3], [], "hexpm", "9a83e3704807298016968db506f9fad0f027de37546eb838b3ae1064c3a0ad62"}, + "makeup": {:hex, :makeup, "1.0.0", "671df94cf5a594b739ce03b0d0316aa64312cee2574b6a44becb83cd90fb05dc", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm", "a10c6eb62cca416019663129699769f0c2ccf39428b3bb3c0cb38c718a0c186d"}, + "makeup_elixir": {:hex, :makeup_elixir, "0.14.0", "cf8b7c66ad1cff4c14679698d532f0b5d45a3968ffbcbfd590339cb57742f1ae", [:mix], [{:makeup, "~> 1.0", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm", "d4b316c7222a85bbaa2fd7c6e90e37e953257ad196dc229505137c5e505e9eff"}, "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"}, "mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"}, "msgpack": {:hex, :msgpack, "0.7.0", "128ae0a2227c7e7a2847c0f0f73551c268464f8c1ee96bffb920bc0a5712b295", [:rebar3], [], "hexpm", "4649353da003e6f438d105e4b1e0f17757f6f5ec8687a6f30875ff3ac4ce2a51"}, -- 2.45.3