-
Notifications
You must be signed in to change notification settings - Fork 35
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom event loop #97
Conversation
CC @thomaseizinger, for some reason it won't let me request a review from anyone? |
That is because I am not listed as a maintainer, I think :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
Thanks for giving this a go! :)
Left a few comments!
Ahh, I see. I can add you as a collaborator if you'd like? Also, do you think it makes sense to tighten up this PR and get it merged soon, and after that tackle modularisation? |
Sure! Much appreciated :)
Yes to both. |
One last thing to be done here: I think now that the future from enum Error {
ActorShutdown,
Disconnected,
Interrupted,
} We could also tackle #89 here and maybe remove the A possible usecase for how senders could interpret |
# Conflicts: # src/context.rs # src/inbox/rx.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
EDIT: holding off on merge until the latest change has been reviewed |
I've added a new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good apart from the removal of -> Self::Stopped
:)
/// The actor is no longer running and disconnected from the sending address. | ||
Disconnected, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we include the actor name via std::any::type_name
in here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We would need a constructor for this to avoid the type parameter:
impl Error {
pub fn disconnected::<A: Any>() - Self {
Self::Disconnected(std::any::type_name::<A>())
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For encapsulation purposes, we could make this enum private and encapsulating it in an opaque error, similar to std::io::Error
but we'd lose exhaustive matching then because users can only check of the types via Error::is_interrupted()
etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that having exhaustive matching is probably useful, so I would rather leave it as it is now, unless there is a compelling reason to encapsulate it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should the interrupted variant also have the name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, should the interrupted variant also have the name?
I guess so? The name is useful because this error may often be question-marked and then appear in an error chain from anyhow
or something. Without the actor name, it is really hard to debug where it came from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In that case, I wonder if it should be extracted as a field:
struct Error {
act: &'static str,
kind: ErrorKind,
}
with the current Error
renamed to ErrorKind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been working on this and it's kinda outgrown this PR, so would you be ok with merging this now and having this feature in a followup? I've pushed my work on that to custom-event-loop-error
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
Strange... the line the CI is failing on doesn't exist?? |
Merge with master. The CI is running on |
Ah, I see! |
# Conflicts: # src/address.rs
This is a POC for custom event loops. I purposefully have not addressed #91 in this draft, as this is simply the minimal set of changes that provide custom event loops, and may serve as a jumping-off point for a PR to address #91. This is a spiritual successor to #51 in a way 馃槃
Closes #89