-
-
Notifications
You must be signed in to change notification settings - Fork 85
Description
A proxy is one category of projects where we have both a client side and a server side. More abstractly, this corresponds to inbound and outbound, or ingress and egress, or north and south. Right now we are in a situation where we:
- either only have one type, which can cause confusion. For example, a TLS tunnel for the incoming HTTP over TLS proxy might add a “secure” marker or similar, but that marker could then confuse the proxy when making a connection on the egress side, where that detail should not matter.
- or we already have explicit wrapper types for specific extension use cases. For example,
ClientSocketInfo, which is a wrapper aroundSocketInfo.
Now that we have cleaned up the context and extension machinery and made it read only, it might be a good moment before 0.3 to introduce more hygiene here. I propose that we introduce wrapper types whose only purpose is to indicate which side they belong to:
#[derive(Debug, Clone, PartialEq, Eq, ...)]
pub struct Egress<T>(pub T);
#[derive(Debug, Clone, PartialEq, Eq, ...)]
pub struct Ingress<T>(pub T);Instead of writing:
ext.get::<SocketInfo>();you would write:
ext.get::<Ingress<SocketInfo>>();
let Ingress(socket_info) = ext.get().unwrap();The concept is simple enough. My main question is what naming is clearest for everyone:
- ingress and egress
- inbound and outbound
- something else?
I think this, combined with adding side specific information to types that might otherwise still be ambiguous, will help us prevent unexpected or unhygienic behaviour. This way, extension extractors can make well informed decisions without any risk of ambiguity.
Please share your feedback. Once we are aligned, I can implement this quickly. I would prefer doing this before 0.3, since it might otherwise break users subtly if they rely on these types without the new side specific wrappers.