Skip to content

Commit e0090ec

Browse files
committed
init
Signed-off-by: chandr-andr (Kiselev Aleksandr) <chandr@chandr.net>
1 parent 6a38f16 commit e0090ec

File tree

3 files changed

+21
-26
lines changed

3 files changed

+21
-26
lines changed

src/driver/connection_pool.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use crate::runtime::tokio_runtime;
22
use deadpool_postgres::{Manager, ManagerConfig, Object, Pool, RecyclingMethod};
3-
use futures::{stream, FutureExt, StreamExt, TryStreamExt};
4-
use pyo3::{pyclass, pyfunction, pymethods, Py, PyAny, Python};
5-
use std::{sync::Arc, time::Duration, vec};
6-
use tokio::time::sleep;
7-
use tokio_postgres::{Config, NoTls};
3+
use futures::{FutureExt, StreamExt, TryStreamExt};
4+
use pyo3::{pyclass, pyfunction, pymethods, Py, PyAny};
5+
use std::{sync::Arc, vec};
6+
use tokio_postgres::Config;
87

98
use crate::{
109
exceptions::rust_errors::{RustPSQLDriverError, RustPSQLDriverPyResult},
@@ -16,7 +15,7 @@ use super::{
1615
common_options::{ConnRecyclingMethod, LoadBalanceHosts, SslMode, TargetSessionAttrs},
1716
connection::Connection,
1817
listener::Listener,
19-
utils::{build_connection_config, build_manager, build_tls, ConfiguredTLS},
18+
utils::{build_connection_config, build_manager, build_tls},
2019
};
2120

2221
/// Make new connection pool.
@@ -215,7 +214,7 @@ pub struct ConnectionPool {
215214
}
216215

217216
impl ConnectionPool {
218-
pub fn build(
217+
#[must_use] pub fn build(
219218
pool: Pool,
220219
pg_config: Config,
221220
ca_file: Option<String>,

src/driver/listener.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
use std::{
22
collections::{hash_map::Entry, HashMap},
33
sync::Arc,
4-
task::Poll,
54
};
65

76
use futures::{stream, FutureExt, StreamExt, TryStreamExt};
8-
use futures_channel::mpsc::{UnboundedReceiver, UnboundedSender};
7+
use futures_channel::mpsc::UnboundedReceiver;
98
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
10-
use postgres_openssl::{MakeTlsConnector, TlsStream};
9+
use postgres_openssl::MakeTlsConnector;
1110
use pyo3::{pyclass, pymethods, Py, PyAny, PyObject, Python};
1211
use tokio::{sync::RwLock, task::AbortHandle};
13-
use tokio_postgres::{AsyncMessage, Client, Config, Connection, NoTls, Socket};
12+
use tokio_postgres::{AsyncMessage, Client, Config};
1413

1514
use crate::{
1615
exceptions::rust_errors::{RustPSQLDriverError, RustPSQLDriverPyResult},
@@ -19,9 +18,6 @@ use crate::{
1918

2019
use super::{
2120
common_options::SslMode,
22-
transaction_options::{
23-
IsolationLevel, ListenerTransactionConfig, ReadVariant, SynchronousCommit,
24-
},
2521
utils::{build_tls, ConfiguredTLS},
2622
};
2723

@@ -40,7 +36,7 @@ pub struct Listener {
4036
}
4137

4238
impl Listener {
43-
pub fn new(
39+
#[must_use] pub fn new(
4440
// name: String,
4541
pg_config: Config,
4642
ca_file: Option<String>,
@@ -49,10 +45,10 @@ impl Listener {
4945
) -> Self {
5046
Listener {
5147
// name: name,
52-
pg_config: pg_config,
53-
ca_file: ca_file,
48+
pg_config,
49+
ca_file,
5450
// transaction_config: transaction_config,
55-
ssl_mode: ssl_mode,
51+
ssl_mode,
5652
channel_callbacks: Default::default(),
5753
listen_abort_handler: Default::default(),
5854
client: Default::default(),
@@ -116,15 +112,15 @@ impl Listener {
116112
match next_element {
117113
Some(n) => match n {
118114
tokio_postgres::AsyncMessage::Notification(n) => {
119-
println!("Notification {:?}", n);
115+
println!("Notification {n:?}");
120116
return Ok(());
121117
}
122118
_ => {
123-
println!("in_in {:?}", n)
119+
println!("in_in {n:?}");
124120
}
125121
},
126122
_ => {
127-
println!("in {:?}", next_element)
123+
println!("in {next_element:?}");
128124
}
129125
}
130126

@@ -211,14 +207,14 @@ impl Listener {
211207
match next_element {
212208
Some(n) => match n {
213209
tokio_postgres::AsyncMessage::Notification(n) => {
214-
println!("Notification {:?}", n);
210+
println!("Notification {n:?}");
215211
}
216212
_ => {
217-
println!("in_in {:?}", n)
213+
println!("in_in {n:?}");
218214
}
219215
},
220216
_ => {
221-
println!("in {:?}", next_element)
217+
println!("in {next_element:?}");
222218
}
223219
}
224220
}

src/driver/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ pub fn build_tls(
197197
Ok(ConfiguredTLS::NoTls)
198198
}
199199

200-
pub fn build_manager(
200+
#[must_use] pub fn build_manager(
201201
mgr_config: ManagerConfig,
202202
pg_config: Config,
203203
configured_tls: ConfiguredTLS,
@@ -212,5 +212,5 @@ pub fn build_manager(
212212
}
213213
}
214214

215-
return mgr;
215+
mgr
216216
}

0 commit comments

Comments
 (0)