fix(deps): bound SQLx pool maintenance and reserve idle counters
This commit is contained in:
1 parent
7aa854de26
commit
284eb8180e
113 files changed
+21092
-2
No files matched your search
+74
@@ -0,0 +1,74 @@
|
||||
// Annoying how deprecation warnings trigger in the same module as the deprecated item.
|
||||
#![allow(deprecated)]
|
||||
// Cargo features are broken in this file.
|
||||
// `AnyKind` may return at some point but it won't be a simple enum.
|
||||
#![allow(unexpected_cfgs)]
|
||||
|
||||
use crate::error::Error;
|
||||
use std::str::FromStr;
|
||||
|
||||
#[deprecated = "not used or returned by any API"]
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum AnyKind {
|
||||
#[cfg(feature = "postgres")]
|
||||
Postgres,
|
||||
|
||||
#[cfg(feature = "mysql")]
|
||||
MySql,
|
||||
|
||||
#[cfg(feature = "_sqlite")]
|
||||
Sqlite,
|
||||
|
||||
#[cfg(feature = "mssql")]
|
||||
Mssql,
|
||||
}
|
||||
|
||||
impl FromStr for AnyKind {
|
||||
type Err = Error;
|
||||
|
||||
fn from_str(url: &str) -> Result<Self, Self::Err> {
|
||||
match url {
|
||||
#[cfg(feature = "postgres")]
|
||||
_ if url.starts_with("postgres:") || url.starts_with("postgresql:") => {
|
||||
Ok(AnyKind::Postgres)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "postgres"))]
|
||||
_ if url.starts_with("postgres:") || url.starts_with("postgresql:") => {
|
||||
Err(Error::Configuration("database URL has the scheme of a PostgreSQL database but the `postgres` feature is not enabled".into()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "mysql")]
|
||||
_ if url.starts_with("mysql:") || url.starts_with("mariadb:") => {
|
||||
Ok(AnyKind::MySql)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mysql"))]
|
||||
_ if url.starts_with("mysql:") || url.starts_with("mariadb:") => {
|
||||
Err(Error::Configuration("database URL has the scheme of a MySQL database but the `mysql` feature is not enabled".into()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "_sqlite")]
|
||||
_ if url.starts_with("sqlite:") => {
|
||||
Ok(AnyKind::Sqlite)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "_sqlite"))]
|
||||
_ if url.starts_with("sqlite:") => {
|
||||
Err(Error::Configuration("database URL has the scheme of a SQLite database but the `sqlite` feature is not enabled".into()))
|
||||
}
|
||||
|
||||
#[cfg(feature = "mssql")]
|
||||
_ if url.starts_with("mssql:") || url.starts_with("sqlserver:") => {
|
||||
Ok(AnyKind::Mssql)
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "mssql"))]
|
||||
_ if url.starts_with("mssql:") || url.starts_with("sqlserver:") => {
|
||||
Err(Error::Configuration("database URL has the scheme of a MSSQL database but the `mssql` feature is not enabled".into()))
|
||||
}
|
||||
|
||||
_ => Err(Error::Configuration(format!("unrecognized database url: {url:?}").into()))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user