Skip to content

Commit

Permalink
khepri_machine: Define the Ra machine version to 0
Browse files Browse the repository at this point in the history
[Why]
This is not required at this point. However, users can query the machine
version without having to worry if the callback is defined (version = 0
when the callback is missing) or not.

[How]
We define the first version to be 0.

As mentionned in the patch, this version, even though it is valid, can't
be returned because the callback spec is too restrictive. Once the spec
is fixed, we can remove the Dialyzer directive added by this commit.
  • Loading branch information
dumbbell committed Oct 19, 2023
1 parent 3860dce commit b42ee54
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/khepri_machine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@
handle_aux/6,
apply/3,
state_enter/2,
overview/1]).
overview/1,
version/0]).

%% For internal use only.
-export([clear_cache/1,
Expand All @@ -74,6 +75,13 @@

-compile({no_auto_import, [apply/3]}).

%% Turn off Dialyzer for `version/0'. It returns a version of 0 but it not
%% allowed by the callback spec as of this writing. See
%% https://github.com/rabbitmq/ra/pull/399 for the pull request which fixes
%% this. Once there is a release of Ra with this patch, the following directive
%% can be removed.
-dialyzer({nowarn_function, version/0}).

-type props() :: #{payload_version := khepri:payload_version(),
child_list_version := khepri:child_list_version()}.
%% Properties attached to each node in the tree structure.
Expand Down Expand Up @@ -1316,6 +1324,9 @@ overview(#?MODULE{config = #config{store_id = StoreId},
triggers => Triggers,
keep_while_conds => KeepWhileConds}.

version() ->
0.

%% -------------------------------------------------------------------
%% Internal functions.
%% -------------------------------------------------------------------
Expand Down

0 comments on commit b42ee54

Please sign in to comment.