Split message sending into two (complementary) methods #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Split message sending into two methods:
Context::send
- Utility method that takesToMessage
, performs conversion and callsContext::send_message
Context::send_message
- Takes aBox<Message>
, resolves the address, performs serialization/deserialization (in debug mode), and transmits the message.Motivation
The previous implementation of
send_message
worked by usingToMessage
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 receivesBox<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 useToMessage
.Test Plan
The current examples and tests should cover the new use-case as the new method is still in the critical path.