实现 Bedrock SQL 存储与部署配置 #24
Generated
-28
@@ -159,12 +159,8 @@ name = "db_connection"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clusters",
|
||||
"mysql",
|
||||
"persistence",
|
||||
"postgres",
|
||||
"serde_json",
|
||||
"sqlite",
|
||||
"sqlx",
|
||||
"tempfile",
|
||||
"thiserror",
|
||||
"tokio",
|
||||
@@ -680,14 +676,6 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mysql"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"persistence",
|
||||
"sqlx",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint-dig"
|
||||
version = "0.8.6"
|
||||
@@ -831,14 +819,6 @@ version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6"
|
||||
|
||||
[[package]]
|
||||
name = "postgres"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"persistence",
|
||||
"sqlx",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "potential_utf"
|
||||
version = "0.1.6"
|
||||
@@ -1159,14 +1139,6 @@ dependencies = [
|
||||
"der",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlite"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"persistence",
|
||||
"sqlx",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sqlx"
|
||||
version = "0.8.6"
|
||||
|
||||
@@ -10,9 +10,6 @@ rust-version = "1.91"
|
||||
clusters = { path = "crates/clusters" }
|
||||
db_connection = { path = "crates/db_connection" }
|
||||
persistence = { path = "crates/persistence" }
|
||||
sqlite = { path = "crates/sqlite" }
|
||||
postgres = { path = "crates/postgres" }
|
||||
mysql = { path = "crates/mysql" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sqlx = { version = "0.8.6", default-features = false, features = ["any", "runtime-tokio", "tls-rustls-ring-webpki"] }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bedrock storage
|
||||
|
||||
Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. SQLite is the default and creates `bedrock.sqlite3` in the current directory on first start.
|
||||
Bedrock stores JSON documents in SQLite, PostgreSQL or MySQL. Each backend has its own module in the `persistence` crate. SQLite is the default and creates `bedrock.sqlite3` in the current directory on first start.
|
||||
|
||||
Set `BEDROCK_DB_CONFIG` to the path of a private JSON deployment configuration to select a different cluster. For example:
|
||||
|
||||
|
||||
@@ -6,14 +6,10 @@ rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
clusters.workspace = true
|
||||
mysql.workspace = true
|
||||
persistence.workspace = true
|
||||
postgres.workspace = true
|
||||
sqlite.workspace = true
|
||||
thiserror.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
serde_json.workspace = true
|
||||
sqlx = { workspace = true, features = ["mysql", "postgres", "sqlite"] }
|
||||
tempfile.workspace = true
|
||||
tokio.workspace = true
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
pub use clusters::{Address, Cluster, ConfigError, DeploymentConfig, Driver, Tls};
|
||||
pub use mysql::{Lease, MySql};
|
||||
pub use persistence::mysql::{Lease, MySql};
|
||||
pub use persistence::{Document, Error as StorageError, Mutation, Revision, Snapshot};
|
||||
|
||||
use clusters::ResolvedDeployment;
|
||||
use persistence::{Reader, Store};
|
||||
use persistence::{Reader, Store, mysql, postgres, sqlite};
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[package]
|
||||
name = "mysql"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
persistence.workspace = true
|
||||
sqlx = { workspace = true, features = ["mysql"] }
|
||||
@@ -6,5 +6,5 @@ rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
serde_json.workspace = true
|
||||
sqlx.workspace = true
|
||||
sqlx = { workspace = true, features = ["mysql", "postgres", "sqlite"] }
|
||||
thiserror.workspace = true
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
//! Shared storage contract for Bedrock's SQL backends.
|
||||
//! Shared storage contract and SQL backends for Bedrock.
|
||||
|
||||
pub mod mysql;
|
||||
pub mod postgres;
|
||||
pub mod sqlite;
|
||||
|
||||
use std::{borrow::Cow, collections::HashSet, fmt::Write, time::Duration};
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use std::{sync::Arc, time::Duration};
|
||||
|
||||
use persistence::{
|
||||
use crate::{
|
||||
Dialect, Error, MYSQL_NOW, Mutation, Reader, Result, Revision, Store, lock_mysql_deployment,
|
||||
pool,
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
//! PostgreSQL connection pools and the Bedrock document layout.
|
||||
|
||||
use persistence::{Dialect, Reader, Result, Store, pool};
|
||||
use crate::{Dialect, Reader, Result, Store, pool};
|
||||
|
||||
const SCHEMA: &[&str] = &[
|
||||
"CREATE TABLE IF NOT EXISTS bedrock_deployments (
|
||||
@@ -1,6 +1,6 @@
|
||||
//! File-backed Bedrock storage for self-hosted deployments.
|
||||
|
||||
use persistence::{Dialect, Reader, Result, Store, pool};
|
||||
use crate::{Dialect, Reader, Result, Store, pool};
|
||||
|
||||
const SCHEMA: &[&str] = &[
|
||||
"CREATE TABLE IF NOT EXISTS bedrock_deployments (
|
||||
@@ -1,9 +0,0 @@
|
||||
[package]
|
||||
name = "postgres"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
persistence.workspace = true
|
||||
sqlx = { workspace = true, features = ["postgres"] }
|
||||
@@ -1,9 +0,0 @@
|
||||
[package]
|
||||
name = "sqlite"
|
||||
version = "0.1.0"
|
||||
edition.workspace = true
|
||||
rust-version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
persistence.workspace = true
|
||||
sqlx = { workspace = true, features = ["sqlite"] }
|
||||
@@ -76,7 +76,7 @@
|
||||
<text x="104" y="732" class="detail">配置由 BEDROCK_DB_CONFIG 指定。</text>
|
||||
<rect x="84" y="821" width="452" height="75" rx="9" fill="#e0eee0" stroke="#8eaf98"/>
|
||||
<text x="104" y="847" class="headline">在已有 PostgreSQL 数据库内初始化</text>
|
||||
<text x="104" y="869" class="detail">postgres 提供 SQL,persistence 在事务里执行。</text>
|
||||
<text x="104" y="869" class="detail">postgres 模块提供 SQL,共用存储层在事务里执行。</text>
|
||||
<text x="104" y="887" class="detail">创建 Bedrock 表并登记 production 部署。</text>
|
||||
<text x="328" y="787" class="detail">进入 Store::initialize()</text>
|
||||
<text x="118" y="909" class="result">成功</text>
|
||||
|
||||
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
Reference in New Issue
Block a user