Skip to content

Commit

Permalink
better external API
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Valiushko committed May 25, 2023
1 parent 9936265 commit f6260ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
17 changes: 6 additions & 11 deletions src/ra.erl
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@
%% membership changes
add_member/2,
add_member/3,
maybe_add_member/2,
maybe_add_member/3,
remove_member/2,
remove_member/3,
leave_and_terminate/3,
Expand Down Expand Up @@ -572,23 +570,20 @@ add_member(ServerLoc, ServerId) ->
%% @see add_member/2
%% @end
-spec add_member(ra_server_id() | [ra_server_id()],
ra_server_id(), timeout()) ->
ra_server_id() | {maybe, ra_server_id()},
timeout()) ->
ra_cmd_ret() |
{error, already_member} |
{error, cluster_change_not_permitted}.
add_member(ServerLoc, {maybe, ServerId}, Timeout) ->
ra_server_proc:command(ServerLoc,
{'$ra_maybe_join', ServerId, after_log_append},
Timeout);
add_member(ServerLoc, ServerId, Timeout) ->
ra_server_proc:command(ServerLoc,
{'$ra_join', ServerId, after_log_append},
Timeout).

maybe_add_member(ServerLoc, ServerId) ->
maybe_add_member(ServerLoc, ServerId, ?DEFAULT_TIMEOUT).
maybe_add_member(ServerLoc, ServerId, Timeout) ->
ra_server_proc:command(ServerLoc,
{'$ra_maybe_join', ServerId, after_log_append},
Timeout).


%% @doc Removes a server from the cluster's membership configuration.
%% This function returns after appending a cluster membership change
%% command to the log.
Expand Down
2 changes: 1 addition & 1 deletion test/ra_voter_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ start_and_join({ClusterName, _} = ServerRef, {_, _} = New) ->
ok.

start_and_maybe_join({ClusterName, _} = ServerRef, {_, _} = New) ->
{ok, _, _} = ra:maybe_add_member(ServerRef, New),
{ok, _, _} = ra:add_member(ServerRef, {maybe, New}),
ok = ra:start_server(default, ClusterName, New, add_machine(), [ServerRef]),
ok.

Expand Down

0 comments on commit f6260ba

Please sign in to comment.