Give datagram receiver access to current connection path #1576
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.
This allows the receiver to differentiate the handling based on the connection's remote address. For example, if a datagram receiver wants to process the payload differently depending on the source address, this allows it to do so. The path a connection takes may change over time, so passing this state on each on_datagram call seems like the best bet.
One alternative design (not thoroughly explored) is to expose the datagram payloads to the Subscriber interface, and just have the datagram provider ignore payloads. Since there are no payloads anywhere in that trait today that I can see, it seems like it might be intentional to not surface them there?
This doesn't fully address #1565, but does surface most of the (by me) currently desired information. Based on poking around the code it seems like there would be more extensive changes required for the Connect struct to gain fields that are generic, I'm not sure it's worth making that investment now.
Call-outs:
The usage of the event API Path struct here is a bit odd -- I'm not sure if there's a better type to be using. Maybe we should be defining a datagram-specific wrapper.
Note also that this will be a breaking change to the datagram trait -- if we wanted to avoid that we can define a new method on the trait with a default implementation that calls the current one, but seems like it might make sense to just make the change while the interface is still unstable.
Testing:
No particular testing yet.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.