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
Modular Context
#91
Comments
Here is an initial draft:
|
This could maybe be done in an extension crate too
How would this pass the context to the actor's
What is the advantage of making them free functions over functions of Context?
In theory, they could also be in an extension crate. |
Depending on how much type-safety we want, I am not sure it can. e.g. I think
I was thinking of
It makes it clear what the minimal public API of xtra is and by having them as free-functions, we eat our own dogfood and can't access internals.
True. |
#[async_trait]
trait RepeatExt {
async fn repeat_every(interval: Duration);
}
#[async_trait]
impl<F, TResolveMarker> RepeatExt for SendFuture<(), F, TResolveMarker>
where F: ...
{
async fn repeat_every(interval: Duration) {
// body
}
} Could work I think. Async trait is only used for brevity - a combinator could be used instead.
I am not sure free functions accomplish this, as they can still be implemented with crate internal features through |
I am also happy to remove the functions for now and introduce an extension crate. I just figured that adding them to the core
It doesn't prevent it but cheating with |
|
Hmm, matter of taste I guess? I guess the reason I'd prefer a free function is because the real goal here is to improve the encapsulation of FWIW I would probably call it like this: xtra::select(context, fut, self).await;
Footnotes
|
We could define let next_message = context.next_message();
xtra::select(next_message, fut, self).await; That is what |
Closing this in favor of #126. |
Without having a better name for this idea, here is what this is about:
With #85, the eventloop in
Context
is becoming very simple. It would amazing if you could polish up the APIs aroundSender
,ActorMessage
etc in such a way that we can expose all these types publicly and provide them as fundamental building blocks for an actor system, together with a "basic" event loop that just reads and dispatches messages.Anything on top like instrumentation, logging or things like #41 could then be solved outside of this library.
The text was updated successfully, but these errors were encountered: