Skip to content

Commit

Permalink
remove maybe_expr
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Valiushko committed Sep 22, 2023
1 parent e0f292f commit 80ccd91
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
33 changes: 17 additions & 16 deletions src/ra_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
%%
-module(ra_server).

-feature(maybe_expr, enable).

-include("ra.hrl").
-include("ra_server.hrl").

Expand Down Expand Up @@ -2947,22 +2945,25 @@ get_membership(#{cfg := #cfg{id = Id, uid = UId}, cluster := Cluster} = State) -
Default = maps:get(membership, State, voter),
get_membership(Cluster, Id, UId, Default).

-spec maybe_promote_peer(ra_server_id(), ra_server_state(), effects()) -> effects().
-spec maybe_promote_peer(ra_server_id(), ra_server_state(), effects()) ->
effects().
maybe_promote_peer(PeerId, #{cluster := Cluster}, Effects) ->
maybe
case Cluster of
#{PeerId := #{match_index := MI,
voter_status := VoterStatus}} ?= Cluster,
#{membership := promotable, target := Target} ?= VoterStatus,
true ?= MI >= Target,
E = {next_event,
{command, {'$ra_join',
#{ts => os:system_time(millisecond)},
#{id => PeerId,
voter_status => VoterStatus#{membership => voter}},
noreply}}},
[E | Effects]
else
_ -> Effects
voter_status := #{membership := promotable,
target := Target} = OldStatus}} when
MI >= Target ->
Promote = {next_event,
{command, {'$ra_join',
#{ts => os:system_time(millisecond)},
#{id => PeerId,
voter_status => OldStatus#{
membership => voter
}},
noreply}}},
[Promote | Effects];
_ ->
Effects
end.

-spec required_quorum(ra_cluster()) -> pos_integer().
Expand Down
2 changes: 0 additions & 2 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
%% @hidden
-module(ra_server_proc).

-feature(maybe_expr, enable).

-behaviour(gen_statem).

-compile({inline, [handle_raft_state/3]}).
Expand Down

0 comments on commit 80ccd91

Please sign in to comment.