Define all cluster drivers in the driver module

This commit is contained in:
2026-11-30 17:59:32 +08:00
parent 353ea1558c
commit 3c551ca0a3
5 changed files with 20 additions and 18 deletions
+4 -2
View File
@@ -6,6 +6,8 @@
箭头从使用方指向定义类型或提供功能的模块。图中省略 `mod` 声明和 `pub use` 导出。 箭头从使用方指向定义类型或提供功能的模块。图中省略 `mod` 声明和 `pub use` 导出。
`driver.rs` 集中定义驱动类型,供 SQL 和对象存储配置模块使用。
```mermaid ```mermaid
flowchart LR flowchart LR
lib["lib.rs"] -->|解析 SQL 配置| sql["sql.rs"] lib["lib.rs"] -->|解析 SQL 配置| sql["sql.rs"]
@@ -13,8 +15,8 @@ flowchart LR
sql -->|ConfigError| lib sql -->|ConfigError| lib
obj -->|ConfigError| lib obj -->|ConfigError| lib
obj -->|ObjectStoreDriver| drv["driver.rs"] sql -->|SqlDriver| drv["driver.rs"]
drv -->|SqlDriver| sql obj -->|ObjectStoreDriver| drv
cat["catalog.rs"] -->|为 DeploymentConfig 实现 CRUD| lib cat["catalog.rs"] -->|为 DeploymentConfig 实现 CRUD| lib
cat -->|统一表示驱动类别| drv cat -->|统一表示驱动类别| drv
+13 -2
View File
@@ -1,6 +1,6 @@
use serde::{Deserialize, Serialize}; //! Driver definitions shared by the backend configuration modules.
use crate::SqlDriver; use serde::{Deserialize, Serialize};
/// Common backend type for catalog lookups in Rust. /// Common backend type for catalog lookups in Rust.
/// ///
@@ -18,6 +18,17 @@ pub enum Driver {
OnlineService(OnlineServiceKind), OnlineService(OnlineServiceKind),
} }
/// The driver in SQL cluster configuration. Serde uses snake_case names such as `postgres`.
/// `SqlDriver::default()` selects `Sqlite`.
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SqlDriver {
#[default]
Sqlite,
Postgres,
Mysql,
}
/// The driver in object storage configuration. Serde reads and writes `S3` as `s3`. /// The driver in object storage configuration. Serde reads and writes `S3` as `s3`.
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)] #[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
+1 -1
View File
@@ -15,7 +15,7 @@ pub use catalog::{Resource, ResourceRef};
pub use driver::*; pub use driver::*;
pub use format::{ConfigFormat, FormatError, ImportFormat}; pub use format::{ConfigFormat, FormatError, ImportFormat};
pub use object_storage::ObjectStorage; pub use object_storage::ObjectStorage;
pub use sql::{Address, Cluster, ResolvedSql, SqlDriver, Tls}; pub use sql::{Address, Cluster, ResolvedSql, Tls};
pub const DOCUMENTS: &str = "documents"; pub const DOCUMENTS: &str = "documents";
+1 -1
View File
@@ -1,7 +1,7 @@
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
use crate::{ConfigError, ObjectStoreDriver}; use crate::{ConfigError, driver::ObjectStoreDriver};
#[derive(Clone, Debug, Deserialize, Serialize)] #[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(deny_unknown_fields)] #[serde(deny_unknown_fields)]
+1 -12
View File
@@ -3,18 +3,7 @@ use std::{fmt, path::Path};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use url::Url; use url::Url;
use crate::ConfigError; use crate::{ConfigError, driver::SqlDriver};
/// The driver in SQL cluster configuration. Serde uses snake_case names such as `postgres`.
/// `SqlDriver::default()` selects `Sqlite`.
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum SqlDriver {
#[default]
Sqlite,
Postgres,
Mysql,
}
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize)] #[derive(Clone, Copy, Debug, Default, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]