Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Triggers: Support simple MFA calls and messages in addition to stored procedures #57

Open
dumbbell opened this issue Feb 18, 2022 · 1 comment
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@dumbbell
Copy link
Member

This idea comes from some feedback on the Erlang forum:

Have you considered maybe supporting callbacks and/or notifications as well as Funs? e.g.

{callback, Mod :: atom(), Fun :: atom()}
{notify, Method :: call | cast | info, Pid :: pid()}

Indeed, it would be nice to have a simple way to specify a function call or a message+PID.

@dumbbell
Copy link
Member Author

dumbbell commented Jan 8, 2025

Some random thoughts from today:

  • khepri_machine:register_trigger/5 could accept the following arguments instead of a stored procedure path:

    khepri_machine:register_trigger(..., {apply, {Mod, Fun, Args}}, ...).
    khepri_machine:register_trigger(..., {send, Pid | RegisteredName, Args}, ...).
  • khepri_event_handler would have to monitor the passed PID and remove the trigger when the process exit. If the argument is a registerend process name, no need to monitor. Monitors would have to be recreated on Khepri startup.

  • The #triggered{} record should be modified to:

    • have a reference or a sequence to distinguish retried executions; can we use the Ra term and index directly?
    • move the path of the stored procedure to the props field and use another field for the other argument types.
  • In the case of apply, the function would be called with the given arguments, plus the one that would be passed to a stored procedure.

  • In the case of send, the message would be of a record, e.g. #khepri_trigger{}, containing the given arguments and the map that would be passed to a stored procedure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant