]> Entropealabs - wampex_router.git/commitdiff
tweaking specs for docs
authorChristopher <chris@entropealabs.com>
Tue, 18 Feb 2020 02:43:45 +0000 (20:43 -0600)
committerChristopher <chris@entropealabs.com>
Tue, 18 Feb 2020 02:43:45 +0000 (20:43 -0600)
lib/wampex/roles/callee.ex
lib/wampex/roles/caller.ex
lib/wampex/roles/peer.ex
lib/wampex/roles/publisher.ex
lib/wampex/roles/subscriber.ex
lib/wampex/session.ex
lib/wampex/transport.ex
test/wampex_test.exs

index 2152e144625e81bf7b427749676cde94403a2e5a..b834d68d60825c830857f7a7059eb37b4912599c 100644 (file)
@@ -18,27 +18,28 @@ defmodule Wampex.Role.Callee do
     Map.put(roles, :callee, %{})
   end
 
-  @spec register(binary()) :: Wampex.message()
+  @spec register(procedure :: binary()) :: Wampex.message()
   def register(procedure) do
     [@register, %{}, procedure]
   end
 
-  @spec unregister(integer()) :: Wampex.message()
-  def unregister(id) do
-    [@unregister, id]
+  @spec unregister(registration_id :: integer()) :: Wampex.message()
+  def unregister(registration_id) do
+    [@unregister, registration_id]
   end
 
-  @spec yield(integer()) :: Wampex.message()
+  @spec yield(request_id :: integer()) :: Wampex.message()
   def yield(request_id) do
     [@yield, request_id, %{}]
   end
 
-  @spec yield(integer(), nonempty_list(any())) :: Wampex.message()
+  @spec yield(request_id :: integer(), arg_l :: 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()
+  @spec yield(request_id :: integer(), arg_l :: nonempty_list(any()), arg_kw :: map()) ::
+          Wampex.message()
   def yield(request_id, arg_l, arg_kw) do
     [@yield, request_id, %{}, arg_l, arg_kw]
   end
index e8d65cc5496d015f6a9ee59aa0719c3af36076e9..5bd5f4dfde0741348feff987e2219707ea773935 100644 (file)
@@ -14,17 +14,18 @@ defmodule Wampex.Role.Caller do
     Map.put(roles, :caller, %{})
   end
 
-  @spec call(binary()) :: Wampex.message()
+  @spec call(procedure :: binary()) :: Wampex.message()
   def call(procedure) do
     [@call, %{}, procedure]
   end
 
-  @spec call(binary(), nonempty_list(any())) :: Wampex.message()
+  @spec call(procedure :: binary(), arg_l :: 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()
+  @spec call(procedure :: binary(), arg_l :: nonempty_list(any()), arg_kw :: map()) ::
+          Wampex.message()
   def call(procedure, arg_l, arg_kw) do
     [@call, %{}, procedure, arg_l, arg_kw]
   end
index 9622fbdcbd2694b4b23f45b31050a6d1428c94e2..a02a4be2a216acc64373f9789d97a70417560500 100644 (file)
@@ -17,12 +17,12 @@ defmodule Wampex.Role.Peer do
   @impl true
   def add(roles), do: roles
 
-  @spec hello(binary(), nonempty_list(module())) :: Wampex.message()
+  @spec hello(realm :: binary(), roles :: 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()
+  @spec goodbye(reason :: binary()) :: Wampex.message()
   def goodbye(reason) do
     [@goodbye, %{}, reason]
   end
index 614a0a1648f4790209dcb81b14d6617b894da0c6..5e625880f641a4efffb6e9f57af01c00241349d5 100644 (file)
@@ -14,17 +14,18 @@ defmodule Wampex.Role.Publisher do
     Map.put(roles, :publisher, %{})
   end
 
-  @spec publish(binary()) :: Wampex.message()
+  @spec publish(topic :: binary()) :: Wampex.message()
   def publish(topic) do
     [@publish, %{}, topic]
   end
 
-  @spec publish(binary(), nonempty_list(any())) :: Wampex.message()
+  @spec publish(topic :: binary(), arg_l :: 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()
+  @spec publish(topic :: binary(), arg_l :: nonempty_list(any()), arg_kw :: map()) ::
+          Wampex.message()
   def publish(topic, arg_l, arg_kw) do
     [@publish, %{}, topic, arg_l, arg_kw]
   end
index a34e02d94383cf662044424a1ba9e6d80a2dcaef..814c3de373ac942cc585e477d0df14ff03c4102c 100644 (file)
@@ -17,14 +17,14 @@ defmodule Wampex.Role.Subscriber do
     Map.put(roles, :subscriber, %{})
   end
 
-  @spec subscribe(binary()) :: Wampex.message()
+  @spec subscribe(topic :: binary()) :: Wampex.message()
   def subscribe(topic) do
     [@subscribe, %{}, topic]
   end
 
-  @spec unsubscribe(integer()) :: Wampex.message()
-  def unsubscribe(sub_id) do
-    [@unsubscribe, sub_id]
+  @spec unsubscribe(subscription_id :: integer()) :: Wampex.message()
+  def unsubscribe(subscription_id) do
+    [@unsubscribe, subscription_id]
   end
 
   @impl true
index a002ca05cec03742aa0aadb1b97db56d9e51543d..81f8d5708a4a17db6ad0b36910ef1d04b5292f9c 100644 (file)
@@ -63,14 +63,14 @@ defmodule Wampex.Session do
   end
 
   @spec cast_send_request(name :: atom() | pid(), request :: Wampex.message()) :: :ok
-  def cast_send_request(p, request) do
-    __MODULE__.cast(p, {:send_request, request})
+  def cast_send_request(name, request) do
+    __MODULE__.cast(name, {:send_request, request})
   end
 
   @spec send_request(name :: atom() | pid(), request :: Wampex.message(), timeout :: integer()) ::
           term()
-  def send_request(p, request, timeout) do
-    __MODULE__.call(p, {:send_request, request}, timeout)
+  def send_request(name, request, timeout) do
+    __MODULE__.call(name, {:send_request, request}, timeout)
   end
 
   defp do_send(r_id, tt, t, request) do
@@ -86,11 +86,11 @@ defmodule Wampex.Session do
     request_id
   end
 
-  def get_request_id(current_id) when current_id == @max_id do
+  defp get_request_id(current_id) when current_id == @max_id do
     1
   end
 
-  def get_request_id(current_id) do
+  defp get_request_id(current_id) do
     current_id + 1
   end
 
index 69175ff73832c0bf6cda7974342b67b0e075e693..4ad963a3ee1610313acb55f30c3686e18fe70cb3 100644 (file)
@@ -1,6 +1,6 @@
 defmodule Wampex.Transport do
   @moduledoc "Behaviour for Transports"
-  @callback send_request(atom() | pid(), Wampex.message()) :: :ok
+  @callback send_request(transport :: atom() | pid(), message :: Wampex.message()) :: :ok
   @callback start_link(
               url: binary(),
               session: Wampex.Session.t(),
index 80197f8c82b3502604946ead42e6f31e68565963..edbcd9ebb7097a67bb1735df6144c3b152dd0137 100644 (file)
@@ -29,14 +29,6 @@ defmodule WampexTest do
     assert Test.Transport = Wampex.transport_name(Test)
   end
 
-  test "get_request_id plus one" do
-    assert 11 = Wampex.Session.get_request_id(10)
-  end
-
-  test "get_request_id resets" do
-    assert 1 = Wampex.Session.get_request_id(9_007_199_254_740_992)
-  end
-
   test "Callee.add" do
     assert %{callee: %{}} = Callee.add(%{})
   end