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

Give datagram receiver access to current connection path #1576

Merged
merged 1 commit into from
Dec 2, 2022

Conversation

Mark-Simulacrum
Copy link
Collaborator

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.

@Mark-Simulacrum
Copy link
Collaborator Author

I'll wait to fix tests/clippy until we decide on whether this is the right general direction or if we want to pursue one of the alternatives.

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.
@Mark-Simulacrum
Copy link
Collaborator Author

Alright, revised implementation to be future-extensible to pass more information in and tests are now also passing.

@camshaft camshaft merged commit f6baade into aws:main Dec 2, 2022
@Mark-Simulacrum Mark-Simulacrum deleted the pass-path-to-receiver branch December 2, 2022 20:03
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.

2 participants