Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite08a38f

Browse files
committed
sync postgres config up with tokio-postgres
1 parent3d0a593 commite08a38f

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

‎postgres/src/config.rs‎

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ use std::sync::Arc;
1313
use std::time::Duration;
1414
use tokio::runtime;
1515
#[doc(inline)]
16-
pubuse tokio_postgres::config::{ChannelBinding,Host,SslMode,TargetSessionAttrs};
16+
pubuse tokio_postgres::config::{
17+
ChannelBinding,Host,LoadBalanceHosts,SslMode,TargetSessionAttrs,
18+
};
1719
use tokio_postgres::error::DbError;
1820
use tokio_postgres::tls::{MakeTlsConnect,TlsConnect};
1921
use tokio_postgres::{Error,Socket};
@@ -43,9 +45,9 @@ use tokio_postgres::{Error, Socket};
4345
/// * `hostaddr` - Numeric IP address of host to connect to. This should be in the standard IPv4 address format,
4446
/// e.g., 172.28.40.9. If your machine supports IPv6, you can also use those addresses.
4547
/// If this parameter is not specified, the value of `host` will be looked up to find the corresponding IP address,
46-
///-or if host specifies an IP address, that value will be used directly.
48+
/// or if host specifies an IP address, that value will be used directly.
4749
/// Using `hostaddr` allows the application to avoid a host name look-up, which might be important in applications
48-
/// with time constraints. However, a host name is required forverify-full SSL certificate verification.
50+
/// with time constraints. However, a host name is required forTLS certificate verification.
4951
/// Specifically:
5052
/// * If `hostaddr` is specified without `host`, the value for `hostaddr` gives the server network address.
5153
/// The connection attempt will fail if the authentication method requires a host name;
@@ -72,6 +74,15 @@ use tokio_postgres::{Error, Socket};
7274
/// * `target_session_attrs` - Specifies requirements of the session. If set to `read-write`, the client will check that
7375
/// the `transaction_read_write` session parameter is set to `on`. This can be used to connect to the primary server
7476
/// in a database cluster as opposed to the secondary read-only mirrors. Defaults to `all`.
77+
/// * `channel_binding` - Controls usage of channel binding in the authentication process. If set to `disable`, channel
78+
/// binding will not be used. If set to `prefer`, channel binding will be used if available, but not used otherwise.
79+
/// If set to `require`, the authentication process will fail if channel binding is not used. Defaults to `prefer`.
80+
/// * `load_balance_hosts` - Controls the order in which the client tries to connect to the available hosts and
81+
/// addresses. Once a connection attempt is successful no other hosts and addresses will be tried. This parameter
82+
/// is typically used in combination with multiple host names or a DNS record that returns multiple IPs. If set to
83+
/// `disable`, hosts and addresses will be tried in the order provided. If set to `random`, hosts will be tried
84+
/// in a random order, and the IP addresses resolved from a hostname will also be tried in a random order. Defaults
85+
/// to `disable`.
7586
///
7687
/// ## Examples
7788
///
@@ -80,7 +91,7 @@ use tokio_postgres::{Error, Socket};
8091
/// ```
8192
///
8293
/// ```not_rust
83-
/// host=/var/run/postgresql,localhost port=1234 user=postgres password='password with spaces'
94+
/// host=/var/lib/postgresql,localhost port=1234 user=postgres password='password with spaces'
8495
/// ```
8596
///
8697
/// ```not_rust
@@ -94,7 +105,7 @@ use tokio_postgres::{Error, Socket};
94105
/// # Url
95106
///
96107
/// This format resembles a URL with a scheme of either `postgres://` or `postgresql://`. All components are optional,
97-
/// and the formataccept query parameters for all of the key-value pairs described in the section above. Multiple
108+
/// and the formataccepts query parameters for all of the key-value pairs described in the section above. Multiple
98109
/// host/port pairs can be comma-separated. Unix socket paths in the host section of the URL should be percent-encoded,
99110
/// as the path component of the URL specifies the database name.
100111
///
@@ -105,15 +116,15 @@ use tokio_postgres::{Error, Socket};
105116
/// ```
106117
///
107118
/// ```not_rust
108-
/// postgresql://user:password@%2Fvar%2Frun%2Fpostgresql/mydb?connect_timeout=10
119+
/// postgresql://user:password@%2Fvar%2Flib%2Fpostgresql/mydb?connect_timeout=10
109120
/// ```
110121
///
111122
/// ```not_rust
112123
/// postgresql://user@host1:1234,host2,host3:5678?target_session_attrs=read-write
113124
/// ```
114125
///
115126
/// ```not_rust
116-
/// postgresql:///mydb?user=user&host=/var/run/postgresql
127+
/// postgresql:///mydb?user=user&host=/var/lib/postgresql
117128
/// ```
118129
#[derive(Clone)]
119130
pubstructConfig{
@@ -396,6 +407,19 @@ impl Config {
396407
self.config.get_channel_binding()
397408
}
398409

410+
/// Sets the host load balancing behavior.
411+
///
412+
/// Defaults to `disable`.
413+
pubfnload_balance_hosts(&mutself,load_balance_hosts:LoadBalanceHosts) ->&mutConfig{
414+
self.config.load_balance_hosts(load_balance_hosts);
415+
self
416+
}
417+
418+
/// Gets the host load balancing behavior.
419+
pubfnget_load_balance_hosts(&self) ->LoadBalanceHosts{
420+
self.config.get_load_balance_hosts()
421+
}
422+
399423
/// Sets the notice callback.
400424
///
401425
/// This callback will be invoked with the contents of every

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp