Skip to content

Commit

Permalink
ra_aux: Expose effective machine version
Browse files Browse the repository at this point in the history
A machine might want this information to determine if it should emit
an effect like `{append, NewCmd}` that can only be handled once a
cluster reaches an effective machine version.
  • Loading branch information
the-mikedavis committed Sep 24, 2024
1 parent f6ab5b9 commit 55c9b81
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/ra_aux.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

-export([
machine_state/1,
effective_machine_version/1,
leader_id/1,
last_applied/1,
members_info/1,
Expand All @@ -17,6 +18,7 @@
]).

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

-opaque internal_state() :: ra_server:state().

Expand All @@ -26,6 +28,11 @@
machine_state(State) ->
maps:get(?FUNCTION_NAME, State).

-spec effective_machine_version(ra_aux:internal_state()) ->
ra_machine:version().
effective_machine_version(#{cfg := Cfg}) ->
Cfg#cfg.effective_machine_version.

-spec leader_id(ra_aux:internal_state()) -> undefined | ra_server_id().
leader_id(State) ->
maps:get(?FUNCTION_NAME, State).
Expand Down

0 comments on commit 55c9b81

Please sign in to comment.