Serve business and admin routes from one backend process

This commit is contained in:
2026-11-30 18:24:21 +08:00
parent 296fb9b1b7
commit 6469d3aad6
9 changed files with 122 additions and 98 deletions
+6 -2
View File
@@ -44,6 +44,10 @@ pub struct Connection {
pub async fn connect(config: &DeploymentConfig) -> Result<Connection, ConnectError> {
let config = config.resolve()?;
Ok(connect_resolved(&config).await?)
}
pub async fn connect_resolved(config: &ResolvedDeployment) -> Result<Connection, StorageError> {
let writer = if config.read_only {
None
} else {
@@ -60,7 +64,7 @@ pub async fn connect(config: &DeploymentConfig) -> Result<Connection, ConnectErr
Some(Writer::Sql(store)) => store.reader(),
Some(Writer::MySql(store)) => store.reader(),
None => {
let reader = reader(&config, &config.primary)?;
let reader = reader(config, &config.primary)?;
reader.revision().await?;
reader
}
@@ -68,7 +72,7 @@ pub async fn connect(config: &DeploymentConfig) -> Result<Connection, ConnectErr
let replicas = config
.replicas
.iter()
.map(|address| reader(&config, address))
.map(|address| reader(config, address))
.collect::<Result<_, _>>()?;
Ok(Connection {
driver: config.driver,
+1 -1
View File
@@ -7,7 +7,7 @@ pub mod postgres;
pub mod sqlite;
pub use clusters::{Address, Cluster, ConfigError, DeploymentConfig, Driver, Tls};
pub use connection::{ConnectError, Connection, ReadPreference, connect};
pub use connection::{ConnectError, Connection, ReadPreference, connect, connect_resolved};
pub use mysql::{Lease, MySql};
pub use common::Error as StorageError;