Send messages all at once
This commit is contained in:
parent
d27518ba76
commit
f03b4b181a
@ -350,11 +350,14 @@ impl Connection {
|
|||||||
.and_then(|()| frontend::describe(b'S', name, &mut describe))
|
.and_then(|()| frontend::describe(b'S', name, &mut describe))
|
||||||
.and_then(|()| Ok(frontend::sync(&mut sync)))
|
.and_then(|()| Ok(frontend::sync(&mut sync)))
|
||||||
.into_future()
|
.into_future()
|
||||||
.and_then(move |()| self.0.send(parse))
|
.and_then(move |()| {
|
||||||
.and_then(|s| s.send(describe))
|
let it = Some(parse).into_iter()
|
||||||
.and_then(|s| s.send(sync))
|
.chain(Some(describe))
|
||||||
.and_then(|s| s.flush())
|
.chain(Some(sync))
|
||||||
.and_then(|s| s.read())
|
.map(Ok::<_, io::Error>);
|
||||||
|
self.0.send_all(futures::stream::iter(it))
|
||||||
|
})
|
||||||
|
.and_then(|s| s.0.read())
|
||||||
.map_err(Error::Io)
|
.map_err(Error::Io)
|
||||||
.boxed() // work around nonlinear trans blowup
|
.boxed() // work around nonlinear trans blowup
|
||||||
.and_then(|(m, s)| {
|
.and_then(|(m, s)| {
|
||||||
@ -484,11 +487,14 @@ impl Connection {
|
|||||||
s
|
s
|
||||||
})
|
})
|
||||||
.into_future()
|
.into_future()
|
||||||
.and_then(|s| s.0.send(bind).map_err(Error::Io))
|
.and_then(|s| {
|
||||||
.and_then(|s| s.send(execute).map_err(Error::Io))
|
let it = Some(bind).into_iter()
|
||||||
.and_then(|s| s.send(sync).map_err(Error::Io))
|
.chain(Some(execute))
|
||||||
.and_then(|s| s.flush().map_err(Error::Io))
|
.chain(Some(sync))
|
||||||
.and_then(|s| s.read().map_err(Error::Io))
|
.map(Ok::<_, io::Error>);
|
||||||
|
s.0.send_all(futures::stream::iter(it)).map_err(Error::Io)
|
||||||
|
})
|
||||||
|
.and_then(|s| s.0.read().map_err(Error::Io))
|
||||||
.and_then(|(m, s)| {
|
.and_then(|(m, s)| {
|
||||||
match m {
|
match m {
|
||||||
backend::Message::BindComplete => Either::A(Ok(Connection(s)).into_future()),
|
backend::Message::BindComplete => Either::A(Ok(Connection(s)).into_future()),
|
||||||
|
Loading…
Reference in New Issue
Block a user