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

feat(core): implement Context::send in the builder-like manner #142

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nerodono
Copy link
Contributor

@nerodono nerodono commented Dec 8, 2024

Adding behavior settings for Context::send could be annoying, we already have functions like unbounded_send, send, send_to, unbounded_send_to, try_send, try_send_to and so on. With turning send into builder, we could achieve having only one function in the Context: Context::send, actions performed on that builder could be divided in two categories

Outcome

Function which finishes building of envelope and sends it, such as

  • ctx.send(..).try_() - try send without waiting for available place in the mailbox
  • ctx.send(..).unbounded() - send envelope unconditionally
  • ctx.send(..).await - wait for place in the destination mailbox and send

Parameters

  • .to(..) - destination

Moreover, we could elide request and request_to functions as well, but it requires more thought though, since ctx.send(..).resolve().await looks nice, but ctx.send(..).all().await seems confusing (Maybe unifying send and request interfaces is quite unfortunate?)

@nerodono nerodono force-pushed the feat/send-builder-poc branch 2 times, most recently from 036421a to a0c4b86 Compare February 23, 2025 15:57
@nerodono nerodono marked this pull request as ready for review February 23, 2025 15:57
@nerodono nerodono force-pushed the feat/send-builder-poc branch from a0c4b86 to 86e21b7 Compare February 23, 2025 15:59
/// ```
///
/// [inter-group routing]: https://actoromicon.rs/ch04-01-routing.html
pub fn try_send<M: Message>(&self, message: M) -> Result<(), TrySendError<M>> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe deprecate those methods in favor of just send?

use tracing::trace;

use crate::{
context::{addrs_with_envelope, e2m, DUMPER},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess some of this functionality now should be here, but I'm quite reluctant to move more code more at this state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant