@@ -254,24 +254,46 @@ impl Config {
254
254
self
255
255
}
256
256
257
+ /// Sets the timeout applied to socket-level connection attempts.
258
+ ///
259
+ /// Note that hostnames can resolve to multiple IP addresses, and this timeout will apply to each address of each
260
+ /// host separately. Defaults to no limit.
261
+ ///
262
+ /// Requires the `runtime` Cargo feature (enabled by default).
257
263
#[ cfg( feature = "runtime" ) ]
258
264
pub fn connect_timeout ( & mut self , connect_timeout : Duration ) -> & mut Config {
259
265
Arc :: make_mut ( & mut self . 0 ) . connect_timeout = Some ( connect_timeout) ;
260
266
self
261
267
}
262
268
269
+ /// Controls the use of TCP keepalive.
270
+ ///
271
+ /// This is ignored for Unix domain socket connections. Defaults to `true`.
272
+ ///
273
+ /// Requires the `runtime` Cargo feature (enabled by default).
263
274
#[ cfg( feature = "runtime" ) ]
264
275
pub fn keepalives ( & mut self , keepalives : bool ) -> & mut Config {
265
276
Arc :: make_mut ( & mut self . 0 ) . keepalives = keepalives;
266
277
self
267
278
}
268
279
280
+ /// Sets the amount of idle time before a keepalive packet is sent on the connection.
281
+ ///
282
+ /// This is ignored for Unix domain sockets, or if the `keepalives` option is disabled. Defaults to 2 hours.
283
+ ///
284
+ /// Requires the `runtime` Cargo feature (enabled by default).
269
285
#[ cfg( feature = "runtime" ) ]
270
286
pub fn keepalives_idle ( & mut self , keepalives_idle : Duration ) -> & mut Config {
271
287
Arc :: make_mut ( & mut self . 0 ) . keepalives_idle = keepalives_idle;
272
288
self
273
289
}
274
290
291
+ /// Sets the requirements of the session.
292
+ ///
293
+ /// This can be used to connect to the primary server in a clustered database rather than one of the read-only
294
+ /// secondary servers. Defaults to `Any`.
295
+ ///
296
+ /// Requires the `runtime` Cargo feature (enabled by default).
275
297
#[ cfg( feature = "runtime" ) ]
276
298
pub fn target_session_attrs (
277
299
& mut self ,
@@ -364,21 +386,27 @@ impl Config {
364
386
Ok ( ( ) )
365
387
}
366
388
367
- pub fn handshake < S , T > ( & self , stream : S , tls_mode : T ) -> Handshake < S , T >
368
- where
369
- S : AsyncRead + AsyncWrite ,
370
- T : TlsMode < S > ,
371
- {
372
- Handshake ( HandshakeFuture :: new ( stream, tls_mode, self . clone ( ) , None ) )
373
- }
374
-
389
+ /// Opens a connection to a PostgreSQL database.
390
+ ///
391
+ /// Requires the `runtime` Cargo feature (enabled by default).
375
392
#[ cfg( feature = "runtime" ) ]
376
393
pub fn connect < T > ( & self , make_tls_mode : T ) -> Connect < T >
377
394
where
378
395
T : MakeTlsMode < Socket > ,
379
396
{
380
397
Connect ( ConnectFuture :: new ( make_tls_mode, Ok ( self . clone ( ) ) ) )
381
398
}
399
+
400
+ /// Connects to a PostgreSQL database over an arbitrary stream.
401
+ ///
402
+ /// All of the settings other than `user`, `password`, `dbname`, `options`, and `application` name are ignored.
403
+ pub fn handshake < S , T > ( & self , stream : S , tls_mode : T ) -> Handshake < S , T >
404
+ where
405
+ S : AsyncRead + AsyncWrite ,
406
+ T : TlsMode < S > ,
407
+ {
408
+ Handshake ( HandshakeFuture :: new ( stream, tls_mode, self . clone ( ) , None ) )
409
+ }
382
410
}
383
411
384
412
impl FromStr for Config {
0 commit comments