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

Split message sending into two (complementary) methods #66

Merged
merged 2 commits into from
May 19, 2023

Conversation

JohnMurray
Copy link
Owner

@JohnMurray JohnMurray commented May 19, 2023

Summary

Split message sending into two methods:

  • Context::send - Utility method that takes ToMessage, performs conversion and calls Context::send_message
  • Context::send_message - Takes a Box<Message>, resolves the address, performs serialization/deserialization (in debug mode), and transmits the message.

Motivation

The previous implementation of send_message worked by using ToMessage as a convenience type to cut down on the boilerplate of sending messages. This worked great, however it had one drawback in that is relied on concrete types.

The ability to also send a Box<Message> allows for patterns, abstractions, or middle-men to be built. Take a load-balancer actor for example. It receives Box<Message>s and then forwards them to an actor in a pool. In this instance, there is no concrete type we're dealing with so it is difficult to use ToMessage.

Test Plan

The current examples and tests should cover the new use-case as the new method is still in the critical path.

@JohnMurray JohnMurray changed the title Send sender fix Split message sending into two (complementary) methods May 19, 2023
@JohnMurray JohnMurray merged commit dc12417 into main May 19, 2023
@JohnMurray JohnMurray deleted the send-sender-fix branch May 19, 2023 18:16
@JohnMurray JohnMurray mentioned this pull request May 19, 2023
6 tasks
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