Skip to content

Commit fc95cdc

Browse files
committed
update docs of connect_tls; remove set no_delay for tcp stream
1 parent e7324e8 commit fc95cdc

File tree

4 files changed

+19
-7
lines changed

4 files changed

+19
-7
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
branches:
55
- release
66
paths:
7-
- '**/Cargo.toml'
7+
- 'Cargo.toml'
88
- '.github/workflows/release.yml'
99

1010
jobs:
@@ -17,7 +17,7 @@ jobs:
1717
package:
1818
- name: async-postgres
1919
registryName: async-postgres
20-
path: async-postgres
20+
path: .
2121
publishPath: /target/package
2222
steps:
2323
- uses: actions/checkout@v2

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ futures = { version = "0.3.4", default-features = false }
2828
async-std = { version = "1.5", features = ["attributes"] }
2929
tokio = { version = "0.2.14", features = ["full"] }
3030
tokio-postgres = "0.5.3"
31+
postgres-native-tls = "0.3.0"
32+
native-tls = "0.2.4"
3133

3234
[features]
3335
all-types = [

src/connect.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,22 @@ const DEFAULT_PORT: u16 = 5432;
1616
/// Connect to postgres server with a tls connector.
1717
///
1818
/// ```rust
19-
/// use async_postgres::connect;
20-
///
19+
/// use async_postgres::connect_tls;
20+
/// use native_tls::{Certificate, TlsConnector};
21+
/// use postgres_native_tls::MakeTlsConnector;
22+
/// use std::fs;
2123
/// use std::error::Error;
2224
/// use async_std::task::spawn;
2325
///
2426
/// async fn play() -> Result<(), Box<dyn Error>> {
25-
/// let url = "host=localhost user=postgres";
26-
/// let (client, conn) = connect(url.parse()?).await?;
27+
/// let cert = fs::read("database_cert.pem")?;
28+
/// let cert = Certificate::from_pem(&cert)?;
29+
/// let connector = TlsConnector::builder()
30+
/// .add_root_certificate(cert)
31+
/// .build()?;
32+
/// let connector = MakeTlsConnector::new(connector);
33+
/// let url = "host=localhost user=postgres sslmode=require";
34+
/// let (client, conn) = connect_tls(url.parse()?, connector).await?;
2735
/// spawn(conn);
2836
/// let row = client.query_one("SELECT * FROM user WHERE id=$1", &[&0]).await?;
2937
/// let value: &str = row.get(0);
@@ -91,7 +99,7 @@ async fn connect_socket(
9199
Host::Tcp(tcp) => {
92100
let fut = TcpStream::connect((tcp.as_str(), port));
93101
let socket = timeout(dur, fut).await?;
94-
socket.set_nodelay(true)?;
102+
// socket.set_nodelay(true)?;
95103
Ok(socket.into())
96104
}
97105
}

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22
33
#![warn(missing_docs)]
44

5+
#[doc(inline)]
56
pub use connect::connect_tls;
7+
#[doc(inline)]
68
pub use socket::Socket;
79
pub use tokio_postgres::*;
810

0 commit comments

Comments
 (0)