v0.3.3-pre.003-fix.001
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-store-postgres-lib/src/runtime.rs
|
||||
// version: 4
|
||||
// version: 5
|
||||
|
||||
const APPLICATION_NAME: &str = "ksp-store";
|
||||
const MAX_CONNECTION_URI_BYTES: usize = 4_096;
|
||||
@@ -143,18 +143,19 @@ pub struct PostgresBackendSettings {
|
||||
connect_timeout: std::time::Duration,
|
||||
connection_uri: std::string::String,
|
||||
create_timeout: std::time::Duration,
|
||||
auto_migrate: bool,
|
||||
max_connections: u32,
|
||||
migration_lock_timeout: std::time::Duration,
|
||||
migration_timeout: std::time::Duration,
|
||||
network: ksp_store_api::RawNetworkId,
|
||||
recycle_timeout: std::time::Duration,
|
||||
schema_autocreate: bool,
|
||||
schema_autoupdate: bool,
|
||||
tls_mode: PostgresBackendTlsMode,
|
||||
wait_timeout: std::time::Duration,
|
||||
}
|
||||
|
||||
impl PostgresBackendSettings {
|
||||
/// Creates the physical PostgreSQL settings bridge from already validated facade-owned values.
|
||||
/// Creates the physical PostgreSQL settings bridge using the legacy single migration switch.
|
||||
#[must_use]
|
||||
pub fn new(
|
||||
network: ksp_store_api::RawNetworkId,
|
||||
@@ -169,8 +170,39 @@ impl PostgresBackendSettings {
|
||||
migration_timeout: std::time::Duration,
|
||||
migration_lock_timeout: std::time::Duration,
|
||||
) -> Self {
|
||||
return Self {
|
||||
return Self::with_schema_policy(
|
||||
network,
|
||||
connection_uri,
|
||||
max_connections,
|
||||
connect_timeout,
|
||||
wait_timeout,
|
||||
create_timeout,
|
||||
recycle_timeout,
|
||||
tls_mode,
|
||||
auto_migrate,
|
||||
auto_migrate,
|
||||
migration_timeout,
|
||||
migration_lock_timeout,
|
||||
);
|
||||
}
|
||||
|
||||
/// Creates the physical PostgreSQL settings bridge with independent schema creation and update policies.
|
||||
#[must_use]
|
||||
pub fn with_schema_policy(
|
||||
network: ksp_store_api::RawNetworkId,
|
||||
connection_uri: impl std::convert::Into<std::string::String>,
|
||||
max_connections: u32,
|
||||
connect_timeout: std::time::Duration,
|
||||
wait_timeout: std::time::Duration,
|
||||
create_timeout: std::time::Duration,
|
||||
recycle_timeout: std::time::Duration,
|
||||
tls_mode: PostgresBackendTlsMode,
|
||||
schema_autocreate: bool,
|
||||
schema_autoupdate: bool,
|
||||
migration_timeout: std::time::Duration,
|
||||
migration_lock_timeout: std::time::Duration,
|
||||
) -> Self {
|
||||
return Self {
|
||||
connect_timeout,
|
||||
connection_uri: connection_uri.into(),
|
||||
create_timeout,
|
||||
@@ -179,6 +211,8 @@ impl PostgresBackendSettings {
|
||||
migration_timeout,
|
||||
network,
|
||||
recycle_timeout,
|
||||
schema_autocreate,
|
||||
schema_autoupdate,
|
||||
tls_mode,
|
||||
wait_timeout,
|
||||
};
|
||||
@@ -203,7 +237,8 @@ impl std::fmt::Debug for PostgresBackendSettings {
|
||||
.debug_struct("PostgresBackendSettings")
|
||||
.field("network", &self.network)
|
||||
.field("connection_uri", &"<redacted>")
|
||||
.field("auto_migrate", &self.auto_migrate)
|
||||
.field("schema_autocreate", &self.schema_autocreate)
|
||||
.field("schema_autoupdate", &self.schema_autoupdate)
|
||||
.field("max_connections", &self.max_connections)
|
||||
.field("migration_timeout", &self.migration_timeout)
|
||||
.field("migration_lock_timeout", &self.migration_lock_timeout)
|
||||
@@ -263,8 +298,15 @@ impl PostgresBackend {
|
||||
tls_mode = settings.tls_mode().code(),
|
||||
"PostgreSQL Store backend established initial physical connection"
|
||||
);
|
||||
let bootstrap_result =
|
||||
crate::bootstrap(&mut client, settings.network(), settings.auto_migrate, settings.migration_timeout, settings.migration_lock_timeout).await;
|
||||
let bootstrap_result = crate::bootstrap(
|
||||
&mut client,
|
||||
settings.network(),
|
||||
settings.schema_autocreate,
|
||||
settings.schema_autoupdate,
|
||||
settings.migration_timeout,
|
||||
settings.migration_lock_timeout,
|
||||
)
|
||||
.await;
|
||||
if let std::result::Result::Err(error) = bootstrap_result {
|
||||
return std::result::Result::Err(error);
|
||||
}
|
||||
@@ -272,7 +314,8 @@ impl PostgresBackend {
|
||||
ksp_logging_lib::debug!(
|
||||
target: crate::TRACING_TARGET,
|
||||
network = settings.network().as_str(),
|
||||
auto_migrate = settings.auto_migrate,
|
||||
schema_autocreate = settings.schema_autocreate,
|
||||
schema_autoupdate = settings.schema_autoupdate,
|
||||
"PostgreSQL Store migration/bootstrap foundation verified"
|
||||
);
|
||||
return std::result::Result::Ok(Self { network: settings.network, pool });
|
||||
|
||||
Reference in New Issue
Block a user