@@ -69,41 +69,41 @@ extern crate futures;
69
69
extern crate tokio_uds;
70
70
71
71
use fallible_iterator:: FallibleIterator ;
72
- use futures:: { Async , Future , IntoFuture , Poll , Sink , StartSend , Stream } ;
73
72
use futures:: future:: Either ;
73
+ use futures:: { Async , Future , IntoFuture , Poll , Sink , StartSend , Stream } ;
74
74
use futures_state_stream:: { FutureExt , StateStream , StreamEvent } ;
75
75
use postgres_protocol:: authentication;
76
- use postgres_protocol:: message:: { backend, frontend} ;
77
76
use postgres_protocol:: message:: backend:: { ErrorFields , ErrorResponseBody } ;
77
+ use postgres_protocol:: message:: { backend, frontend} ;
78
78
use postgres_shared:: rows:: RowData ;
79
79
use std:: collections:: { HashMap , VecDeque } ;
80
80
use std:: fmt;
81
81
use std:: io;
82
- use std:: sync:: Arc ;
83
82
use std:: sync:: atomic:: { AtomicUsize , Ordering , ATOMIC_USIZE_INIT } ;
84
83
use std:: sync:: mpsc:: { self , Receiver , Sender } ;
84
+ use std:: sync:: Arc ;
85
85
use tokio_core:: reactor:: Handle ;
86
86
87
- #[ doc( inline) ]
88
- pub use postgres_shared:: { error, params, types, CancelData , Notification } ;
89
87
#[ doc( inline) ]
90
88
pub use error:: Error ;
89
+ #[ doc( inline) ]
90
+ pub use postgres_shared:: { error, params, types, CancelData , Notification } ;
91
91
92
92
use error:: { DbError , UNDEFINED_COLUMN , UNDEFINED_TABLE } ;
93
93
use params:: { ConnectParams , IntoConnectParams } ;
94
+ use rows:: Row ;
94
95
use sink:: SinkExt ;
95
96
use stmt:: { Column , Statement } ;
96
97
use stream:: PostgresStream ;
97
98
use tls:: Handshake ;
98
99
use transaction:: Transaction ;
99
100
use types:: { Field , FromSql , IsNull , Kind , Oid , ToSql , Type , CHAR , NAME , OID } ;
100
- use rows:: Row ;
101
101
102
102
#[ macro_use]
103
103
mod macros;
104
104
pub mod rows;
105
- pub mod stmt;
106
105
mod sink;
106
+ pub mod stmt;
107
107
mod stream;
108
108
pub mod tls;
109
109
pub mod transaction;
@@ -151,6 +151,7 @@ where
151
151
Ok ( params) => Either :: A ( stream:: connect (
152
152
params. host ( ) . clone ( ) ,
153
153
params. port ( ) ,
154
+ params. keepalive ( ) ,
154
155
tls_mode,
155
156
handle,
156
157
) ) ,
@@ -302,8 +303,13 @@ impl Connection {
302
303
{
303
304
let fut = match params. into_connect_params ( ) {
304
305
Ok ( params) => Either :: A (
305
- stream:: connect ( params. host ( ) . clone ( ) , params. port ( ) , tls_mode, handle)
306
- . map ( |s| ( s, params) ) ,
306
+ stream:: connect (
307
+ params. host ( ) . clone ( ) ,
308
+ params. port ( ) ,
309
+ params. keepalive ( ) ,
310
+ tls_mode,
311
+ handle,
312
+ ) . map ( |s| ( s, params) ) ,
307
313
) ,
308
314
Err ( e) => Either :: B ( Err ( error:: connect ( e) ) . into_future ( ) ) ,
309
315
} ;
@@ -781,9 +787,7 @@ impl Connection {
781
787
Either :: A ( Ok ( ( Kind :: Simple , c) ) . into_future ( ) )
782
788
} ;
783
789
784
- Either :: B ( kind. map (
785
- move |( k, c) | ( Type :: _new ( name, oid, k, schema) , c) ,
786
- ) )
790
+ Either :: B ( kind. map ( move |( k, c) | ( Type :: _new ( name, oid, k, schema) , c) ) )
787
791
} )
788
792
. boxed2 ( )
789
793
}
@@ -834,9 +838,7 @@ impl Connection {
834
838
oid : Oid ,
835
839
) -> Box < Future < Item = ( Vec < String > , Connection ) , Error = ( Error , Connection ) > + Send > {
836
840
self . setup_typeinfo_enum_query ( )
837
- . and_then ( move |c| {
838
- c. raw_execute ( TYPEINFO_ENUM_QUERY , "" , & [ OID ] , & [ & oid] )
839
- } )
841
+ . and_then ( move |c| c. raw_execute ( TYPEINFO_ENUM_QUERY , "" , & [ OID ] , & [ & oid] ) )
840
842
. and_then ( |c| c. read_rows ( ) . collect ( ) )
841
843
. and_then ( |( r, c) | {
842
844
let mut variants = vec ! [ ] ;
@@ -888,9 +890,7 @@ impl Connection {
888
890
oid : Oid ,
889
891
) -> Box < Future < Item = ( Vec < Field > , Connection ) , Error = ( Error , Connection ) > + Send > {
890
892
self . setup_typeinfo_composite_query ( )
891
- . and_then ( move |c| {
892
- c. raw_execute ( TYPEINFO_COMPOSITE_QUERY , "" , & [ OID ] , & [ & oid] )
893
- } )
893
+ . and_then ( move |c| c. raw_execute ( TYPEINFO_COMPOSITE_QUERY , "" , & [ OID ] , & [ & oid] ) )
894
894
. and_then ( |c| c. read_rows ( ) . collect ( ) )
895
895
. and_then ( |( r, c) | {
896
896
futures:: stream:: iter_ok ( r) . fold ( ( vec ! [ ] , c) , |( mut fields, c) , row| {
@@ -983,9 +983,7 @@ impl Connection {
983
983
. send_all2 ( futures:: stream:: iter_ok :: < _ , io:: Error > ( it) )
984
984
. map_err ( |( e, s, _) | ( error:: io ( e) , Connection ( s) ) )
985
985
} )
986
- . and_then ( |s| {
987
- s. 0 . read ( ) . map_err ( |( e, s) | ( error:: io ( e) , Connection ( s) ) )
988
- } )
986
+ . and_then ( |s| s. 0 . read ( ) . map_err ( |( e, s) | ( error:: io ( e) , Connection ( s) ) ) )
989
987
. and_then ( |( m, s) | match m {
990
988
backend:: Message :: BindComplete => Either :: A ( Ok ( Connection ( s) ) . into_future ( ) ) ,
991
989
backend:: Message :: ErrorResponse ( body) => Either :: B ( Connection ( s) . ready_err ( body) ) ,
@@ -1003,9 +1001,8 @@ impl Connection {
1003
1001
. and_then ( |( m, s) | match m {
1004
1002
backend:: Message :: DataRow ( _) => Connection ( s) . finish_execute ( ) . boxed2 ( ) ,
1005
1003
backend:: Message :: CommandComplete ( body) => {
1006
- let r = body. tag ( ) . map ( |tag| {
1007
- tag. split_whitespace ( ) . last ( ) . unwrap ( ) . parse ( ) . unwrap_or ( 0 )
1008
- } ) ;
1004
+ let r = body. tag ( )
1005
+ . map ( |tag| tag. split_whitespace ( ) . last ( ) . unwrap ( ) . parse ( ) . unwrap_or ( 0 ) ) ;
1009
1006
1010
1007
match r {
1011
1008
Ok ( n) => Connection ( s) . ready ( n) . boxed2 ( ) ,
0 commit comments