Skip to content

Commit

Permalink
khepri_machine: Migrate to the new Ra aux API
Browse files Browse the repository at this point in the history
  • Loading branch information
the-mikedavis committed Sep 19, 2024
1 parent 006c194 commit f456cae
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/khepri_machine.erl
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
%% ra_machine callbacks.
-export([init/1,
init_aux/1,
handle_aux/6,
handle_aux/5,
apply/3,
state_enter/2,
snapshot_installed/4,
Expand Down Expand Up @@ -1222,14 +1222,13 @@ init(Params) ->
init_aux(StoreId) ->
#khepri_machine_aux{store_id = StoreId}.

-spec handle_aux(RaState, Type, Command, AuxState, LogState, MachineState) ->
{no_reply, AuxState, LogState} when
-spec handle_aux(RaState, Type, Command, AuxState, IntState) ->
{no_reply, AuxState, IntState} when
RaState :: ra_server:ra_state(),
Type :: {call, ra:from()} | cast,
Command :: term(),
AuxState :: aux_state(),
LogState :: ra_log:state(),
MachineState :: state().
IntState :: ra_aux:internal_state().
%% @private

handle_aux(
Expand All @@ -1238,12 +1237,12 @@ handle_aux(
old_props = OldProps,
new_props = NewProps,
projection = Projection},
AuxState, LogState, _MachineState) ->
AuxState, IntState) ->
khepri_projection:trigger(Projection, Path, OldProps, NewProps),
{no_reply, AuxState, LogState};
{no_reply, AuxState, IntState};
handle_aux(
_RaState, cast, restore_projections, AuxState, LogState,
State) ->
_RaState, cast, restore_projections, AuxState, IntState) ->
State = ra_aux:machine_state(IntState),
Tree = get_tree(State),
ProjectionTree = get_projections(State),
khepri_pattern_tree:foreach(
Expand All @@ -1252,16 +1251,17 @@ handle_aux(
[restore_projection(Projection, Tree, PathPattern) ||
Projection <- Projections]
end),
{no_reply, AuxState, LogState};
{no_reply, AuxState, IntState};
handle_aux(
_RaState, cast,
#restore_projection{projection = Projection, pattern = PathPattern},
AuxState, LogState, State) ->
AuxState, IntState) ->
State = ra_aux:machine_state(IntState),
Tree = get_tree(State),
ok = restore_projection(Projection, Tree, PathPattern),
{no_reply, AuxState, LogState};
handle_aux(_RaState, _Type, _Command, AuxState, LogState, _MachineState) ->
{no_reply, AuxState, LogState}.
{no_reply, AuxState, IntState};
handle_aux(_RaState, _Type, _Command, AuxState, IntState) ->
{no_reply, AuxState, IntState}.

restore_projection(Projection, Tree, PathPattern) ->
_ = khepri_projection:init(Projection),
Expand Down

0 comments on commit f456cae

Please sign in to comment.