Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/khepri.erl
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,23 @@
%% khepri_machine:split_command_options/2} and {@link
%% khepri_machine:split_put_options/2} must be adapted.

-type trigger_options() :: #{where =>
khepri_event_handler:trigger_exec_loc() | local}.
%% Options specific to trigger registrations.
%%
%% <ul>
%% <li>`where' allows to indicate on which member(s) of the cluster a
%% triggered action should be executed. With `{member, MemberNode}', if the
%% target member is not part of the cluster at the time the action is
%% triggered, the trigger is executed on the leader. The special value `local'
%% means that the node running `khepri_machine:register_trigger/5' will
%% execute the trigger (if it is a member of the cluster at the time the
%% action is triggered).</li>
%% </ul>
%%
%% NOTE: When this list of trigger options is modified, {@link
%% khepri_machine:split_command_options/2} must be adapted.

-type fold_fun() :: fun((khepri_path:native_path(),
khepri:node_props(),
khepri:fold_acc()) -> khepri:fold_acc()).
Expand Down Expand Up @@ -524,6 +541,7 @@
query_options/0,
tree_options/0,
put_options/0,
trigger_options/0,

fold_fun/0,
fold_acc/0,
Expand Down Expand Up @@ -2848,7 +2866,7 @@ register_trigger(TriggerId, EventFilter, StoredProcPath) ->
TriggerId :: trigger_id(),
EventFilter :: khepri_evf:event_filter_or_compat(),
StoredProcPath :: khepri_path:path(),
Options :: command_options(),
Options :: command_options() | khepri:trigger_options(),
Ret :: ok | error().
%% @doc Registers a trigger.
%%
Expand Down Expand Up @@ -2881,7 +2899,7 @@ register_trigger(TriggerId, EventFilter, StoredProcPath, Options)
TriggerId :: trigger_id(),
EventFilter :: khepri_evf:event_filter_or_compat(),
StoredProcPath :: khepri_path:path(),
Options :: command_options(),
Options :: command_options() | khepri:trigger_options(),
Ret :: ok | error().
%% @doc Registers a trigger.
%%
Expand Down
6 changes: 5 additions & 1 deletion src/khepri_event_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,17 @@
%% It is the stored procedure pointed to by the path in the triggered action's
%% arguments.

-type trigger_exec_loc() :: leader.
-type trigger_exec_loc() :: leader | {member, node()} | all_members.
%% Where to execute the triggered action.
%%
%% It supports the following locations:
%% <ul>
%% <li>`leader': the action is executed on the leader node at the time the
%% action is triggered.</li>
%% <li>`{member, Member}': the action is executed on the given node if it is a
%% member of the cluster, or the leader otherwise.</li>
%% <li>`all_members': the action is executed on all members of the
%% cluster.</li>
%% </ul>

-type trigger_descriptor() :: #khepri_trigger{}.
Expand Down
Loading
Loading