Skip to content

Commit 015c499

Browse files
authored
refactor(app/outbound): Connect fields are not pub (#3895)
this structure exposes its fields, but those fields are never accessed elsewhere, aside from test code. this commit removes the `pub` directives from the address and tls fields. in their stead, test interfaces are added to allow the `tagged_transport` test suite to function. Signed-off-by: katelyn martin <kate@buoyant.io>
1 parent ea75ac0 commit 015c499

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

linkerd/app/outbound/src/tcp/connect.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use std::task::{Context, Poll};
88

99
#[derive(Clone, Debug)]
1010
pub struct Connect {
11-
pub addr: Remote<ServerAddr>,
12-
pub tls: tls::ConditionalClientTls,
11+
addr: Remote<ServerAddr>,
12+
tls: tls::ConditionalClientTls,
1313
}
1414

1515
/// Prevents outbound connections on the loopback interface, unless the
@@ -77,6 +77,12 @@ where
7777

7878
// === impl Connect ===
7979

80+
impl Connect {
81+
pub fn new(addr: Remote<ServerAddr>, tls: tls::ConditionalClientTls) -> Self {
82+
Self { addr, tls }
83+
}
84+
}
85+
8086
impl svc::Param<Remote<ServerAddr>> for Connect {
8187
fn param(&self) -> Remote<ServerAddr> {
8288
self.addr
@@ -88,3 +94,14 @@ impl svc::Param<tls::ConditionalClientTls> for Connect {
8894
self.tls.clone()
8995
}
9096
}
97+
98+
#[cfg(test)]
99+
impl Connect {
100+
pub fn addr(&self) -> &Remote<ServerAddr> {
101+
&self.addr
102+
}
103+
104+
pub fn tls(&self) -> &tls::ConditionalClientTls {
105+
&self.tls
106+
}
107+
}

linkerd/app/outbound/src/tcp/tagged_transport.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,7 @@ where
6767
let tls: tls::ConditionalClientTls = ep.param();
6868
if let tls::ConditionalClientTls::None(reason) = tls {
6969
trace!(%reason, "Not attempting opaque transport");
70-
let target = Connect {
71-
addr: ep.param(),
72-
tls,
73-
};
70+
let target = Connect::new(ep.param(), tls);
7471
return Box::pin(self.inner.connect(target).err_into::<Error>());
7572
}
7673

@@ -109,10 +106,10 @@ where
109106

110107
let protocol: Option<SessionProtocol> = ep.param();
111108

112-
let connect = self.inner.connect(Connect {
113-
addr: Remote(ServerAddr((addr.ip(), connect_port).into())),
109+
let connect = self.inner.connect(Connect::new(
110+
Remote(ServerAddr((addr.ip(), connect_port).into())),
114111
tls,
115-
});
112+
));
116113
Box::pin(async move {
117114
let (mut io, meta) = connect.await.map_err(Into::into)?;
118115

@@ -203,9 +200,9 @@ mod test {
203200
) -> impl Fn(Connect) -> futures::future::Ready<Result<(tokio_test::io::Mock, ConnectMeta), io::Error>>
204201
{
205202
move |ep| {
206-
let Remote(ServerAddr(sa)) = ep.addr;
203+
let Remote(ServerAddr(sa)) = ep.addr();
207204
assert_eq!(sa.port(), 4143);
208-
assert!(ep.tls.is_some());
205+
assert!(ep.tls().is_some());
209206
let buf = header.encode_prefaced_buf().expect("Must encode");
210207
let io = tokio_test::io::Builder::new()
211208
.write(&buf[..])
@@ -225,9 +222,9 @@ mod test {
225222

226223
let svc = TaggedTransport {
227224
inner: service_fn(|ep: Connect| {
228-
let Remote(ServerAddr(sa)) = ep.addr;
225+
let Remote(ServerAddr(sa)) = ep.addr();
229226
assert_eq!(sa.port(), 4321);
230-
assert!(ep.tls.is_none());
227+
assert!(ep.tls().is_none());
231228
let io = tokio_test::io::Builder::new().write(b"hello").build();
232229
let meta = tls::ConnectMeta {
233230
socket: Local(ClientAddr(([0, 0, 0, 0], 0).into())),

0 commit comments

Comments
 (0)