Skip to content

Commit

Permalink
Merge pull request #474 from rabbitmq/md/aux/machine-version
Browse files Browse the repository at this point in the history
ra_aux: Expose effective machine version, current term
  • Loading branch information
kjnilsson authored Oct 16, 2024
2 parents f6ab5b9 + ace731e commit d7e3c31
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/ra_aux.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

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

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

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

Expand All @@ -26,6 +29,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 All @@ -34,6 +42,10 @@ leader_id(State) ->
last_applied(State) ->
maps:get(?FUNCTION_NAME, State).

-spec current_term(ra_aux:internal_state()) -> ra_term().
current_term(State) ->
maps:get(?FUNCTION_NAME, State).

-spec members_info(ra_aux:internal_state()) -> ra_cluster().
members_info(State) ->
ra_server:state_query(?FUNCTION_NAME, State).
Expand Down

0 comments on commit d7e3c31

Please sign in to comment.