jaydoane commented on code in PR #5013:
URL: https://github.com/apache/couchdb/pull/5013#discussion_r1536682236
##########
src/mem3/src/mem3.erl:
##########
@@ -423,31 +424,127 @@ engine(Opts) when is_list(Opts) ->
%% Check whether a node is up or down
%% side effect: set up a connection to Node if there not yet is one.
--spec ping(Node :: atom()) -> pong | pang.
+-spec ping(Node :: atom()) -> pos_integer() | Error :: term().
Review Comment:
Is there any reason to leave this backward compatible, or is changing it
fair game?
##########
src/mem3/src/mem3.erl:
##########
@@ -423,31 +424,127 @@ engine(Opts) when is_list(Opts) ->
%% Check whether a node is up or down
%% side effect: set up a connection to Node if there not yet is one.
--spec ping(Node :: atom()) -> pong | pang.
+-spec ping(Node :: atom()) -> pos_integer() | Error :: term().
ping(Node) ->
- ping(Node, ?PING_TIMEOUT_IN_MS).
+ [{Node, Res}] = ping_nodes([Node]),
+ Res.
--spec ping(Node :: atom(), Timeout :: pos_integer()) -> pong | pang.
+-spec ping(Node :: atom(), Timeout :: pos_integer()) -> pos_integer() | Error
:: term().
ping(Node, Timeout) when is_atom(Node) ->
- %% The implementation of the function is copied from
- %% lib/kernel/src/net_adm.erl with addition of a Timeout
- case
- catch gen:call(
- {net_kernel, Node},
- '$gen_call',
- {is_auth, node()},
- Timeout
- )
- of
- {ok, yes} ->
- pong;
- _ ->
- erlang:disconnect_node(Node),
- pang
+ [{Node, Res}] = ping_nodes([Node], Timeout),
+ Res.
+
+-spec ping_nodes() -> [{atom(), pos_integer() | Error :: term()}].
Review Comment:
I wonder if the type spec might be clearer if you used `node()` instead of
`atom()`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]