Define all cluster drivers in the driver module
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
|
||||
箭头从使用方指向定义类型或提供功能的模块。图中省略 `mod` 声明和 `pub use` 导出。
|
||||
|
||||
`driver.rs` 集中定义驱动类型,供 SQL 和对象存储配置模块使用。
|
||||
|
||||
```mermaid
|
||||
flowchart LR
|
||||
lib["lib.rs"] -->|解析 SQL 配置| sql["sql.rs"]
|
||||
@@ -13,8 +15,8 @@ flowchart LR
|
||||
|
||||
sql -->|ConfigError| lib
|
||||
obj -->|ConfigError| lib
|
||||
obj -->|ObjectStoreDriver| drv["driver.rs"]
|
||||
drv -->|SqlDriver| sql
|
||||
sql -->|SqlDriver| drv["driver.rs"]
|
||||
obj -->|ObjectStoreDriver| drv
|
||||
|
||||
cat["catalog.rs"] -->|为 DeploymentConfig 实现 CRUD| lib
|
||||
cat -->|统一表示驱动类别| drv
|
||||
|
||||
@@ -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.
|
||||
///
|
||||
@@ -18,6 +18,17 @@ pub enum Driver {
|
||||
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`.
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, Eq, PartialEq)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
@@ -15,7 +15,7 @@ pub use catalog::{Resource, ResourceRef};
|
||||
pub use driver::*;
|
||||
pub use format::{ConfigFormat, FormatError, ImportFormat};
|
||||
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";
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use crate::{ConfigError, ObjectStoreDriver};
|
||||
use crate::{ConfigError, driver::ObjectStoreDriver};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
||||
@@ -3,18 +3,7 @@ use std::{fmt, path::Path};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use url::Url;
|
||||
|
||||
use crate::ConfigError;
|
||||
|
||||
/// 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,
|
||||
}
|
||||
use crate::{ConfigError, driver::SqlDriver};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, Deserialize, Serialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
|
||||
Reference in New Issue
Block a user