From 2ebc0120fd5f7e877ab82ea5ba91c237640cd267 Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Thu, 19 Aug 2021 20:23:54 +0000 Subject: [PATCH 1/3] sort sort --- src/connector/mysql.rs | 124 +++++++++++++++++++------------------- src/connector/postgres.rs | 106 ++++++++++++++++---------------- src/pooled.rs | 6 ++ src/single.rs | 36 +++++++---- 4 files changed, 147 insertions(+), 125 deletions(-) diff --git a/src/connector/mysql.rs b/src/connector/mysql.rs index be120bb3a..9ac36b7da 100644 --- a/src/connector/mysql.rs +++ b/src/connector/mysql.rs @@ -110,7 +110,7 @@ impl MysqlUrl { self.url.port().unwrap_or(3306) } - /// The connection timeout. + /// The connect timeout. pub fn connect_timeout(&self) -> Option { self.query_params.connect_timeout } @@ -151,32 +151,22 @@ impl MysqlUrl { fn parse_query_params(url: &Url) -> Result { let mut ssl_opts = my::SslOpts::default(); ssl_opts = ssl_opts.with_danger_accept_invalid_certs(true); + let mut use_ssl = false; + let mut connect_timeout = Some(Duration::from_secs(5)); let mut connection_limit = None; - let mut use_ssl = false; + let mut pool_timeout = Some(Duration::from_secs(10)); + let mut socket = None; let mut socket_timeout = None; - let mut connect_timeout = Some(Duration::from_secs(5)); - let mut pool_timeout = Some(Duration::from_secs(10)); - let mut max_connection_lifetime = None; - let mut max_idle_connection_lifetime = Some(Duration::from_secs(300)); let mut prefer_socket = None; + let mut statement_cache_size = 1000; + let mut max_connection_lifetime = None; + let mut max_idle_connection_lifetime = Some(Duration::from_secs(300)); for (k, v) in url.query_pairs() { match k.as_ref() { - "connection_limit" => { - let as_int: usize = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - - connection_limit = Some(as_int); - } - "statement_cache_size" => { - statement_cache_size = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - } "sslcert" => { use_ssl = true; ssl_opts = ssl_opts.with_root_cert_path(Some(Path::new(&*v).to_path_buf())); @@ -189,54 +179,66 @@ impl MysqlUrl { use_ssl = true; ssl_opts = ssl_opts.with_password(Some(v.to_string())); } - "socket" => { - socket = Some(v.replace("(", "").replace(")", "")); - } - "socket_timeout" => { - let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - socket_timeout = Some(Duration::from_secs(as_int)); - } - "prefer_socket" => { - let as_bool = v - .parse::() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - prefer_socket = Some(as_bool) + "sslaccept" => { + match v.as_ref() { + "strict" => { + ssl_opts = ssl_opts.with_danger_accept_invalid_certs(false); + } + "accept_invalid_certs" => {} + _ => { + tracing::debug!( + message = "Unsupported SSL accept mode, defaulting to `accept_invalid_certs`", + mode = &*v + ); + } + }; } "connect_timeout" => { let as_int = v - .parse::() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse::() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + connect_timeout = match as_int { 0 => None, _ => Some(Duration::from_secs(as_int)), }; } - "pool_timeout" => { - let as_int = v - .parse::() + "connection_limit" => { + let as_int: usize = v + .parse() .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + connection_limit = Some(as_int); + } + "pool_timeout" => { + let as_int = v + .parse::() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + pool_timeout = match as_int { 0 => None, _ => Some(Duration::from_secs(as_int)), }; } - "sslaccept" => { - match v.as_ref() { - "strict" => { - ssl_opts = ssl_opts.with_danger_accept_invalid_certs(false); - } - "accept_invalid_certs" => {} - _ => { - tracing::debug!( - message = "Unsupported SSL accept mode, defaulting to `accept_invalid_certs`", - mode = &*v - ); - } - }; + "socket" => { + socket = Some(v.replace("(", "").replace(")", "")); + } + "socket_timeout" => { + let as_int = v + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + socket_timeout = Some(Duration::from_secs(as_int)); + } + "prefer_socket" => { + let as_bool = v + .parse::() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + prefer_socket = Some(as_bool) + } + "statement_cache_size" => { + statement_cache_size = v + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; } "max_connection_lifetime" => { let as_int = v @@ -267,17 +269,17 @@ impl MysqlUrl { } Ok(MysqlUrlQueryParams { + use_ssl, ssl_opts, + connect_timeout, connection_limit, - use_ssl, + pool_timeout, socket, socket_timeout, - connect_timeout, - pool_timeout, - max_connection_lifetime, - max_idle_connection_lifetime, prefer_socket, statement_cache_size, + max_connection_lifetime, + max_idle_connection_lifetime, }) } @@ -318,17 +320,17 @@ impl MysqlUrl { #[derive(Debug, Clone)] pub(crate) struct MysqlUrlQueryParams { + use_ssl: bool, ssl_opts: my::SslOpts, + connect_timeout: Option, connection_limit: Option, - use_ssl: bool, + pool_timeout: Option, socket: Option, socket_timeout: Option, - connect_timeout: Option, - pool_timeout: Option, - max_connection_lifetime: Option, - max_idle_connection_lifetime: Option, prefer_socket: Option, statement_cache_size: usize, + max_connection_lifetime: Option, + max_idle_connection_lifetime: Option, } impl Mysql { diff --git a/src/connector/postgres.rs b/src/connector/postgres.rs index 74f4f4cda..b2b3d3318 100644 --- a/src/connector/postgres.rs +++ b/src/connector/postgres.rs @@ -260,24 +260,31 @@ impl PostgresUrl { } fn parse_query_params(url: &Url) -> Result { - let mut connection_limit = None; let mut schema = None; + let mut pg_bouncer = false; + + let mut ssl_mode = SslMode::Prefer; let mut certificate_file = None; let mut identity_file = None; let mut identity_password = None; let mut ssl_accept_mode = SslAcceptMode::AcceptInvalidCerts; - let mut ssl_mode = SslMode::Prefer; - let mut host = None; - let mut socket_timeout = None; + let mut connect_timeout = Some(Duration::from_secs(5)); + let mut connection_limit = None; let mut pool_timeout = Some(Duration::from_secs(10)); - let mut pg_bouncer = false; + + let mut host = None; + let mut socket_timeout = None; + let mut statement_cache_size = 500; let mut max_connection_lifetime = None; let mut max_idle_connection_lifetime = Some(Duration::from_secs(300)); for (k, v) in url.query_pairs() { match k.as_ref() { + "schema" => { + schema = Some(v.to_string()); + } "pgbouncer" => { pg_bouncer = v .parse() @@ -302,11 +309,6 @@ impl PostgresUrl { "sslpassword" => { identity_password = Some(v.to_string()); } - "statement_cache_size" => { - statement_cache_size = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - } "sslaccept" => { match v.as_ref() { "strict" => { @@ -320,56 +322,58 @@ impl PostgresUrl { message = "Unsupported SSL accept mode, defaulting to `strict`", mode = &*v ); - + ssl_accept_mode = SslAcceptMode::Strict; } }; } - "schema" => { - schema = Some(v.to_string()); - } - "connection_limit" => { - let as_int: usize = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - connection_limit = Some(as_int); - } - "host" => { - host = Some(v.to_string()); - } - "socket_timeout" => { - let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - socket_timeout = Some(Duration::from_secs(as_int)); - } "connect_timeout" => { let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + if as_int == 0 { connect_timeout = None; } else { connect_timeout = Some(Duration::from_secs(as_int)); } } - "pool_timeout" => { - let as_int = v + "connection_limit" => { + let as_int: usize = v .parse() .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + connection_limit = Some(as_int); + } + "pool_timeout" => { + let as_int = v + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + if as_int == 0 { pool_timeout = None; } else { pool_timeout = Some(Duration::from_secs(as_int)); } } - "max_connection_lifetime" => { + "host" => { + host = Some(v.to_string()); + } + "socket_timeout" => { let as_int = v + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + socket_timeout = Some(Duration::from_secs(as_int)); + } + "statement_cache_size" => { + statement_cache_size = v .parse() .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + } + "max_connection_lifetime" => { + let as_int = v + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + if as_int == 0 { max_connection_lifetime = None; } else { @@ -380,10 +384,10 @@ impl PostgresUrl { let as_int = v .parse() .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - - if as_int == 0 { - max_idle_connection_lifetime = None; - } else { + + if as_int == 0 { + max_idle_connection_lifetime = None; + } else { max_idle_connection_lifetime = Some(Duration::from_secs(as_int)); } } @@ -394,20 +398,20 @@ impl PostgresUrl { } Ok(PostgresUrlQueryParams { + schema, + pg_bouncer, + ssl_mode, ssl_params: SslParams { certificate_file, identity_file, ssl_accept_mode, identity_password: Hidden(identity_password), }, - connection_limit, - schema, - ssl_mode, - host, connect_timeout, + connection_limit, pool_timeout, + host, socket_timeout, - pg_bouncer, statement_cache_size, max_connection_lifetime, max_idle_connection_lifetime, @@ -445,15 +449,15 @@ impl PostgresUrl { #[derive(Debug, Clone)] pub(crate) struct PostgresUrlQueryParams { - ssl_params: SslParams, - connection_limit: Option, schema: Option, - ssl_mode: SslMode, pg_bouncer: bool, - host: Option, - socket_timeout: Option, + ssl_mode: SslMode, + ssl_params: SslParams, connect_timeout: Option, + connection_limit: Option, pool_timeout: Option, + host: Option, + socket_timeout: Option, statement_cache_size: usize, max_connection_lifetime: Option, max_idle_connection_lifetime: Option, diff --git a/src/pooled.rs b/src/pooled.rs index 8e878f511..87ce33b52 100644 --- a/src/pooled.rs +++ b/src/pooled.rs @@ -25,6 +25,11 @@ //! //! - `connection_limit` defines the maximum number of connections opened to the //! database. +//! - `pool_timeout` defined in seconds. If all connections are in use, the +//! database will return a `PoolTimeout` error after waiting for the given time. +//! If set to zero, no timeout. +//! - `max_connection_lifetime`, TODO +//! - `max_idle_connection_lifetime`, TODO //! //! ## SQLite //! @@ -105,6 +110,7 @@ //! - `connectTimeout` defined in seconds (default: 5). Connecting to a //! database will return a `ConnectTimeout` error if taking more than the //! defined value. Defaults to 5 seconds, disabled if set to zero. +//! //! - `poolTimeout` defined in seconds. If all connections are in use, the //! database will return a `Timeout` error after waiting for the given time. //! If set to zero, no timeout. diff --git a/src/single.rs b/src/single.rs index 177cc250c..3693a54fa 100644 --- a/src/single.rs +++ b/src/single.rs @@ -59,6 +59,14 @@ impl Quaint { /// /// PostgreSQL: /// + /// - `schema` the default search path. + /// - `pgbouncer` either `true` or `false`. If set, allows usage with the + /// pgBouncer connection pool in transaction mode. Additionally a transaction + /// is required for every query for the mode to work. When starting a new + /// transaction, a deallocation query `DEALLOCATE ALL` is executed right after + /// `BEGIN` to avoid possible collisions with statements created in other + /// sessions. + /// /// - `sslmode` either `disable`, `prefer` or `require`. [Read more](https://docs.rs/tokio-postgres/0.5.0-alpha.1/tokio_postgres/config/enum.SslMode.html) /// - `sslcert` should point to a PEM certificate file. /// - `sslidentity` should point to a PKCS12 certificate database. @@ -67,22 +75,18 @@ impl Quaint { /// certificate needs to be valid and in the CA certificates. /// `accept_invalid_certs` accepts any certificate from the server and can /// lead to weakened security. Defaults to `strict`. - /// - `schema` the default search path. + /// + /// - `connect_timeout` defined in seconds (default: 5). Connecting to a + /// database will return a `ConnectTimeout` error if taking more than the + /// defined value. + /// /// - `host` additionally the host can be given as a parameter, typically in /// cases when connectiong to the database through a unix socket to /// separate the database name from the database path, such as /// `postgresql:///dbname?host=/var/run/postgresql`. /// - `socket_timeout` defined in seconds. If set, a query will return a /// `Timeout` error if it fails to resolve before given time. - /// - `connect_timeout` defined in seconds (default: 5). Connecting to a - /// database will return a `ConnectTimeout` error if taking more than the - /// defined value. - /// - `pgbouncer` either `true` or `false`. If set, allows usage with the - /// pgBouncer connection pool in transaction mode. Additionally a transaction - /// is required for every query for the mode to work. When starting a new - /// transaction, a deallocation query `DEALLOCATE ALL` is executed right after - /// `BEGIN` to avoid possible collisions with statements created in other - /// sessions. + /// /// - `statement_cache_size`, number of prepared statements kept cached. /// Defaults to 500, which means caching is off. If `pgbouncer` mode is enabled, /// caching is always off. @@ -96,13 +100,19 @@ impl Quaint { /// certificate needs to be valid and in the CA certificates. /// `accept_invalid_certs` accepts any certificate from the server and can /// lead to weakened security. Defaults to `strict`. + /// + /// - `connect_timeout` defined in seconds (default: 5). Connecting to a + /// database will return a `ConnectTimeout` error if taking more than the + /// defined value. + /// /// - `socket` needed when connecting to MySQL database through a unix /// socket. When set, the host parameter is dismissed. /// - `socket_timeout` defined in seconds. If set, a query will return a /// `Timeout` error if it fails to resolve before given time. - /// - `connect_timeout` defined in seconds (default: 5). Connecting to a - /// database will return a `ConnectTimeout` error if taking more than the - /// defined value. + /// + /// - `statement_cache_size`, number of prepared statements kept cached. + /// Defaults to 500, which means caching is off. If `pgbouncer` mode is enabled, + /// caching is always off. /// /// Microsoft SQL Server: /// From ebd75008c7337c21f81048bfc7eaee1730699d41 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 19 Aug 2021 20:24:46 +0000 Subject: [PATCH 2/3] Format Rust code using rustfmt --- src/connector/mysql.rs | 24 ++++++++++++------------ src/connector/postgres.rs | 36 ++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/connector/mysql.rs b/src/connector/mysql.rs index 9ac36b7da..d707b7aba 100644 --- a/src/connector/mysql.rs +++ b/src/connector/mysql.rs @@ -156,11 +156,11 @@ impl MysqlUrl { let mut connect_timeout = Some(Duration::from_secs(5)); let mut connection_limit = None; let mut pool_timeout = Some(Duration::from_secs(10)); - + let mut socket = None; let mut socket_timeout = None; let mut prefer_socket = None; - + let mut statement_cache_size = 1000; let mut max_connection_lifetime = None; let mut max_idle_connection_lifetime = Some(Duration::from_secs(300)); @@ -195,9 +195,9 @@ impl MysqlUrl { } "connect_timeout" => { let as_int = v - .parse::() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse::() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + connect_timeout = match as_int { 0 => None, _ => Some(Duration::from_secs(as_int)), @@ -212,9 +212,9 @@ impl MysqlUrl { } "pool_timeout" => { let as_int = v - .parse::() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse::() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + pool_timeout = match as_int { 0 => None, _ => Some(Duration::from_secs(as_int)), @@ -225,14 +225,14 @@ impl MysqlUrl { } "socket_timeout" => { let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; socket_timeout = Some(Duration::from_secs(as_int)); } "prefer_socket" => { let as_bool = v - .parse::() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + .parse::() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; prefer_socket = Some(as_bool) } "statement_cache_size" => { diff --git a/src/connector/postgres.rs b/src/connector/postgres.rs index b2b3d3318..b7b032692 100644 --- a/src/connector/postgres.rs +++ b/src/connector/postgres.rs @@ -268,11 +268,11 @@ impl PostgresUrl { let mut identity_file = None; let mut identity_password = None; let mut ssl_accept_mode = SslAcceptMode::AcceptInvalidCerts; - + let mut connect_timeout = Some(Duration::from_secs(5)); let mut connection_limit = None; let mut pool_timeout = Some(Duration::from_secs(10)); - + let mut host = None; let mut socket_timeout = None; @@ -322,16 +322,16 @@ impl PostgresUrl { message = "Unsupported SSL accept mode, defaulting to `strict`", mode = &*v ); - + ssl_accept_mode = SslAcceptMode::Strict; } }; } "connect_timeout" => { let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + if as_int == 0 { connect_timeout = None; } else { @@ -346,9 +346,9 @@ impl PostgresUrl { } "pool_timeout" => { let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + if as_int == 0 { pool_timeout = None; } else { @@ -360,8 +360,8 @@ impl PostgresUrl { } "socket_timeout" => { let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; socket_timeout = Some(Duration::from_secs(as_int)); } "statement_cache_size" => { @@ -371,9 +371,9 @@ impl PostgresUrl { } "max_connection_lifetime" => { let as_int = v - .parse() - .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - + .parse() + .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; + if as_int == 0 { max_connection_lifetime = None; } else { @@ -384,10 +384,10 @@ impl PostgresUrl { let as_int = v .parse() .map_err(|_| Error::builder(ErrorKind::InvalidConnectionArguments).build())?; - - if as_int == 0 { - max_idle_connection_lifetime = None; - } else { + + if as_int == 0 { + max_idle_connection_lifetime = None; + } else { max_idle_connection_lifetime = Some(Duration::from_secs(as_int)); } } From d401bcb58bb6ce75bd836ab3d576c2b565db9cfa Mon Sep 17 00:00:00 2001 From: Jan Piotrowski Date: Fri, 20 Aug 2021 17:39:36 +0000 Subject: [PATCH 3/3] sort --- src/pooled.rs | 53 +++++++++++++++++++++++++++------------------------ src/single.rs | 14 ++++++-------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/pooled.rs b/src/pooled.rs index 87ce33b52..c65a5b383 100644 --- a/src/pooled.rs +++ b/src/pooled.rs @@ -25,9 +25,6 @@ //! //! - `connection_limit` defines the maximum number of connections opened to the //! database. -//! - `pool_timeout` defined in seconds. If all connections are in use, the -//! database will return a `PoolTimeout` error after waiting for the given time. -//! If set to zero, no timeout. //! - `max_connection_lifetime`, TODO //! - `max_idle_connection_lifetime`, TODO //! @@ -43,6 +40,14 @@ //! //! ## PostgreSQL //! +//! - `schema` the default search path. +//! - `pgbouncer` either `true` or `false`. If set, allows usage with the +//! pgBouncer connection pool in transaction mode. Additionally a transaction +//! is required for every query for the mode to work. When starting a new +//! transaction, a deallocation query `DEALLOCATE ALL` is executed right after +//! `BEGIN` to avoid possible collisions with statements created in other +//! sessions. +//! //! - `sslmode` either `disable`, `prefer` or `require`. [Read more](https://docs.rs/tokio-postgres/0.5.0-alpha.1/tokio_postgres/config/enum.SslMode.html) //! - `sslcert` should point to a PEM certificate file. //! - `sslidentity` should point to a PKCS12 certificate database. @@ -51,27 +56,23 @@ //! certificate needs to be valid and in the CA certificates. //! `accept_invalid_certs` accepts any certificate from the server and can //! lead to weakened security. Defaults to `accept_invalid_certs`. -//! - `schema` the default search path. +//! +//! - `connect_timeout` defined in seconds. Connecting to a +//! database will return a `ConnectTimeout` error if taking more than the +//! defined value. Defaults to 5 seconds, if set to 0, no timeout. +//! //! - `host` additionally the host can be given as a parameter, typically in //! cases when connectiong to the database through a unix socket to //! separate the database name from the database path, such as //! `postgresql:///dbname?host=/var/run/postgresql`. //! - `socket_timeout` defined in seconds. If set, a query will return a //! `Timeout` error if it fails to resolve before given time. -//! - `connect_timeout` defined in seconds. Connecting to a -//! database will return a `ConnectTimeout` error if taking more than the -//! defined value. Defaults to 5 seconds, if set to 0, no timeout. +//! //! - `pool_timeout` defined in seconds. If all connections are in use, the //! database will return a `PoolTimeout` error after waiting for the given time. -//! If set to zero, no timeout. -//! - `pgbouncer` either `true` or `false`. If set, allows usage with the -//! pgBouncer connection pool in transaction mode. Additionally a transaction -//! is required for every query for the mode to work. When starting a new -//! transaction, a deallocation query `DEALLOCATE ALL` is executed right after -//! `BEGIN` to avoid possible collisions with statements created in other -//! sessions. //! - `statement_cache_size`, number of prepared statements kept cached. -//! Defaults to 500. If `pgbouncer` mode is enabled, caching is always off. +//! Defaults to 500, which means caching is off. If `pgbouncer` mode is enabled, +//! caching is always off. //! //! ## MySQL //! @@ -81,14 +82,17 @@ //! - `sslaccept` either `strict` or `accept_invalid_certs`. If strict, the //! certificate needs to be valid and in the CA certificates. //! `accept_invalid_certs` accepts any certificate from the server and can -//! lead to weakened security. Defaults to `strict`. +//! lead to weakened security. Defaults to `accept_invalid_certs`. +//! +//! - `connect_timeout` defined in seconds. Connecting to a +//! database will return a `ConnectTimeout` error if taking more than the +//! defined value. Defaults to 5 seconds, if set to 0, no timeout. +//! //! - `socket` needed when connecting to MySQL database through a unix //! socket. When set, the host parameter is dismissed. //! - `socket_timeout` defined in seconds. If set, a query will return a //! `Timeout` error if it fails to resolve before given time. -//! - `connect_timeout` defined in seconds. Connecting to a -//! database will return a `ConnectTimeout` error if taking more than the -//! defined value. Defaults to 5 seconds, if set to 0, no timeout. +//! //! - `pool_timeout` defined in seconds. If all connections are in use, the //! database will return a `PoolTimeout` error after waiting for the given time. //! If set to zero, no timeout. @@ -97,12 +101,14 @@ //! //! ## Microsoft SQL Server //! -//! - `encrypt` if set to `true` encrypts all traffic over TLS. If `false`, only -//! the login details are encrypted. A special value `DANGER_PLAINTEXT` will -//! disable TLS completely, including sending login credentials as plaintext. //! - `user` sets the login name. //! - `password` sets the login password. //! - `database` sets the database to connect to. +//! - `schema` the name of the lookup schema. Only stored to the connection, +//! must be used in every query to be effective. +//! - `encrypt` if set to `true` encrypts all traffic over TLS. If `false`, only +//! the login details are encrypted. A special value `DANGER_PLAINTEXT` will +//! disable TLS completely, including sending login credentials as plaintext. //! - `trustServerCertificate` if set to `true`, accepts any kind of certificate //! from the server. //! - `socketTimeout` defined in seconds. If set, a query will return a @@ -110,14 +116,11 @@ //! - `connectTimeout` defined in seconds (default: 5). Connecting to a //! database will return a `ConnectTimeout` error if taking more than the //! defined value. Defaults to 5 seconds, disabled if set to zero. -//! //! - `poolTimeout` defined in seconds. If all connections are in use, the //! database will return a `Timeout` error after waiting for the given time. //! If set to zero, no timeout. //! - `connectionLimit` defines the maximum number of connections opened to the //! database. -//! - `schema` the name of the lookup schema. Only stored to the connection, -//! must be used in every query to be effective. //! - `isolationLevel` the transaction isolation level. Possible values: //! `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, `SNAPSHOT`, //! `SERIALIZABLE`. diff --git a/src/single.rs b/src/single.rs index 3693a54fa..ef59d44bc 100644 --- a/src/single.rs +++ b/src/single.rs @@ -99,7 +99,7 @@ impl Quaint { /// - `sslaccept` either `strict` or `accept_invalid_certs`. If strict, the /// certificate needs to be valid and in the CA certificates. /// `accept_invalid_certs` accepts any certificate from the server and can - /// lead to weakened security. Defaults to `strict`. + /// lead to weakened security. Defaults to `accept_invalid_certs`. /// /// - `connect_timeout` defined in seconds (default: 5). Connecting to a /// database will return a `ConnectTimeout` error if taking more than the @@ -116,12 +116,14 @@ impl Quaint { /// /// Microsoft SQL Server: /// - /// - `encrypt` if set to `true` encrypts all traffic over TLS. If `false`, only - /// the login details are encrypted. A special value `DANGER_PLAINTEXT` will - /// disable TLS completely, including sending login credentials as plaintext. /// - `user` sets the login name. /// - `password` sets the login password. /// - `database` sets the database to connect to. + /// - `schema` the name of the lookup schema. Only stored to the connection, + /// must be used in every query to be effective. + /// - `encrypt` if set to `true` encrypts all traffic over TLS. If `false`, only + /// the login details are encrypted. A special value `DANGER_PLAINTEXT` will + /// disable TLS completely, including sending login credentials as plaintext. /// - `trustServerCertificate` if set to `true`, accepts any kind of certificate /// from the server. /// - `socketTimeout` defined in seconds. If set, a query will return a @@ -129,10 +131,6 @@ impl Quaint { /// - `connectTimeout` defined in seconds (default: 5). Connecting to a /// database will return a `ConnectTimeout` error if taking more than the /// defined value. - /// - `connectionLimit` defines the maximum number of connections opened to the - /// database. - /// - `schema` the name of the lookup schema. Only stored to the connection, - /// must be used in every query to be effective. /// - `isolationLevel` the transaction isolation level. Possible values: /// `READ UNCOMMITTED`, `READ COMMITTED`, `REPEATABLE READ`, `SNAPSHOT`, /// `SERIALIZABLE`.