Skip to content

Commit

Permalink
Allow passing a minimum effective machine version with commands
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Sep 12, 2023
1 parent f2e1ee2 commit 0af728e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/ra_server.erl
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
{notify, command_correlation(), pid()} |
noreply.

-type command_options() :: #{reply_mode := command_reply_mode()}.
-type command_options() :: #{reply_mode := command_reply_mode(),
minimum_effective_machine_version =>
ra_machine:version()}.

-type command() :: {command_type(), command_meta(),
UserCommand :: term(), command_reply_mode()} |
Expand Down
13 changes: 11 additions & 2 deletions src/ra_server_proc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1626,8 +1626,17 @@ read_chunks_and_send_rpc(RPC0,
Res1
end.

validate_command_options(#{reply_mode := ReplyMode}, State) ->
validate_command_options(ReplyMode, State);
validate_command_options(#{reply_mode := ReplyMode} = Options,
#state{server_state =
#{cfg := #cfg{effective_machine_version =
MacVsn}}} = State) ->
case Options of
#{minimum_effective_machine_version := MinVsn} when MinVsn > MacVsn ->
{error, {mismatched_machine_version, {minimum, MinVsn},
{actual, MacVsn}}};
_ ->
validate_command_options(ReplyMode, State)
end;
validate_command_options(ReplyMode, #state{conf = Conf}) ->
%% For backwards compatibility, check if the options were supplied as
%% just the reply mode.
Expand Down

0 comments on commit 0af728e

Please sign in to comment.