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

Actor monitoring #476

Open
Thomasdezeeuw opened this issue Jun 7, 2021 · 3 comments
Open

Actor monitoring #476

Thomasdezeeuw opened this issue Jun 7, 2021 · 3 comments
Labels
idea An idea, open to discussion.

Comments

@Thomasdezeeuw
Copy link
Owner

Erlang has a concept of process monitoring, which allows a process (actor) to know if another process stopped. Some resources about them:

I tried to replicated this concept in ActorRef::join (#468), which returns Future<Output = ()> which completes once an actor is stopped. But this doesn't give enough information. For testing for example you would also like to know if the actor stopped normally or returned an error (and wasn't restarted).

So I think we should expand the API: ActorRef::monitor(&self) -> Monitor, where Monitor is a Future<Output = ExitStatus>,

enum ExitStatus {
    Ok,
    StoppedEarly, // Or Error.
}

Some alternative names: JoinResult, RunResult, ExitResult, I'm not a huge fan of the Result suffix as that reminds me of the Result type, but many we can use that.

@Thomasdezeeuw
Copy link
Owner Author

This also relates to the other APIs such as ActorGroup::join_all (#472) and test::join, test::join_many and test::join_all (#470).

@Thomasdezeeuw
Copy link
Owner Author

A possible implementation would be for heph-inbox::Manager to implement fn set_exit_status(self, ExiStatus). Then a new Sender::monitor API similar to that of Sender::join, but it returns this ExitStatus.

@Thomasdezeeuw
Copy link
Owner Author

Could maybe use something like Thomasdezeeuw/inbox#32 for this.

@Thomasdezeeuw Thomasdezeeuw added the idea An idea, open to discussion. label Sep 18, 2021
@Thomasdezeeuw Thomasdezeeuw unpinned this issue Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
idea An idea, open to discussion.
Projects
None yet
Development

No branches or pull requests

1 participant