Skip to content

Commit 29210bb

Browse files
committed
Add Connection::close
1 parent fd1724a commit 29210bb

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

postgres-tokio/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,15 @@ impl Connection {
581581
.boxed()
582582
}
583583

584+
pub fn close(self) -> BoxFuture<(), Error> {
585+
let mut terminate = vec![];
586+
frontend::terminate(&mut terminate);
587+
self.0.send(terminate)
588+
.map(|_| ())
589+
.map_err(Error::Io)
590+
.boxed()
591+
}
592+
584593
pub fn cancel_data(&self) -> CancelData {
585594
self.0.cancel_data
586595
}

postgres-tokio/src/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use error::{Error, ConnectError, SqlState};
88
fn basic() {
99
let mut l = Core::new().unwrap();
1010
let handle = l.handle();
11-
let done = Connection::connect("postgres://postgres@localhost", &handle);
12-
let conn = l.run(done).unwrap();
13-
assert!(conn.cancel_data().process_id != 0);
11+
let done = Connection::connect("postgres://postgres@localhost", &handle)
12+
.then(|c| c.unwrap().close());
13+
l.run(done).unwrap();
1414
}
1515

1616
#[test]

0 commit comments

Comments
 (0)