Skip to content

Commit f6cb7ea

Browse files
committed
Cleanup
1 parent b1c9b45 commit f6cb7ea

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

postgres-tokio/src/lib.rs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,17 @@ impl Connection {
161161
-> BoxFuture<Connection, ConnectError>
162162
where T: IntoConnectParams
163163
{
164-
let params = match params.into_connect_params() {
165-
Ok(params) => params,
166-
Err(e) => return futures::failed(ConnectError::ConnectParams(e)).boxed(),
164+
let fut = match params.into_connect_params() {
165+
Ok(params) => {
166+
Either::A(stream::connect(params.host().clone(), params.port(), tls_mode, handle)
167+
.map(|s| (s, params)))
168+
}
169+
Err(e) => Either::B(Err(ConnectError::ConnectParams(e)).into_future())
167170
};
168171

169-
stream::connect(params.host().clone(), params.port(), tls_mode, handle)
170-
.map(|s| {
172+
fut.map(|(s, params)| {
171173
let (sender, receiver) = mpsc::channel();
172-
Connection(InnerConnection {
174+
(Connection(InnerConnection {
173175
stream: s,
174176
close_sender: sender,
175177
close_receiver: receiver,
@@ -179,9 +181,9 @@ impl Connection {
179181
secret_key: 0,
180182
},
181183
next_stmt_id: 0,
182-
})
184+
}), params)
183185
})
184-
.and_then(|s| s.startup(params))
186+
.and_then(|(s, params)| s.startup(params))
185187
.and_then(|(s, params)| s.handle_auth(params))
186188
.and_then(|s| s.finish_startup())
187189
.boxed()

0 commit comments

Comments
 (0)