rabbitmq / ra

A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Other
798 stars 93 forks source link

New handle_aux/5 API that provides a better and safer API into Ra internals. #414

Closed kjnilsson closed 4 months ago

kjnilsson commented 5 months ago

ra_machine:handle_aux/6 callback was experimental and provided both too much access to the log internals as well as not enough access to ra server state such as membership information. This PR addresses this with a new ra_machine:handle_aux/5 callback that should be preferred going forward. This is accompanied with a new module ra_aux that provides a safe API to query and interact with the ra log and ra server internal state.

-callback handle_aux(ra_server:ra_state(),
                     {call, From :: from()} | cast,
                     Command :: term(),
                     AuxState,
                     State) ->
    {reply, Reply :: term(), AuxState, State} |
    {reply, Reply :: term(), AuxState, State, effects()} |
    {no_reply, AuxState, State} |
    {no_reply, AuxState, State, effects()}
      when AuxState :: term(),
           State :: ra_aux:state().