v0.2.12-pre.004
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// file: crates/ksp-app-solprices-desk/src/app_state.rs
|
||||
// version: 2
|
||||
// version: 3
|
||||
|
||||
//! Shared backend state owned by the SOL Prices Desk Tauri application.
|
||||
|
||||
@@ -7,13 +7,13 @@
|
||||
pub(crate) struct AppState {
|
||||
config_management: ksp_config_lib::ConfigManagement,
|
||||
logging_runtime: std::sync::Mutex<LoggingRuntimeState>,
|
||||
offchain_transport_startup: crate::OffchainTransportStartup,
|
||||
market_price_runtime: crate::MarketPriceRuntime,
|
||||
splash_settings: crate::SplashSettings,
|
||||
splash_sequence_started: std::sync::atomic::AtomicBool,
|
||||
}
|
||||
|
||||
impl crate::AppState {
|
||||
/// Initializes Config ownership, composite-managed Logging and the Config-selected Off-chain Transport runtime.
|
||||
/// Initializes Config ownership, composite-managed Logging and the provider-neutral market-price runtime.
|
||||
pub(crate) fn initialize(arguments: &[std::ffi::OsString]) -> ksp_core_lib::Result<Self> {
|
||||
let config_management = crate::config_management(arguments);
|
||||
let config_management = match config_management {
|
||||
@@ -35,6 +35,11 @@ impl crate::AppState {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let market_price_runtime = crate::MarketPriceRuntime::new(offchain_transport_startup);
|
||||
let market_price_runtime = match market_price_runtime {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let splash_settings = crate::SplashSettings::load();
|
||||
let splash_settings = match splash_settings {
|
||||
std::result::Result::Ok(value) => value,
|
||||
@@ -52,14 +57,19 @@ impl crate::AppState {
|
||||
fallback_active: logging_startup.fallback_active,
|
||||
startup_diagnostic: logging_startup.startup_diagnostic,
|
||||
}),
|
||||
offchain_transport_startup,
|
||||
market_price_runtime,
|
||||
splash_settings,
|
||||
splash_sequence_started: std::sync::atomic::AtomicBool::new(false),
|
||||
});
|
||||
}
|
||||
|
||||
/// Builds the safe runtime status exposed before provider rows and refresh commands are introduced.
|
||||
pub(crate) fn runtime_status(&self) -> ksp_core_lib::Result<crate::RuntimeStatusDto> {
|
||||
/// Lists the current provider-neutral market-price rows without triggering network refresh.
|
||||
pub(crate) fn list_market_prices(&self) -> ksp_core_lib::Result<std::vec::Vec<crate::MarketPriceProviderRowDto>> {
|
||||
return self.market_price_runtime.list_rows();
|
||||
}
|
||||
|
||||
/// Builds the safe runtime status exposed by the SOL Prices Desk shell.
|
||||
pub(crate) fn runtime_status(&self) -> ksp_core_lib::Result<crate::MarketPriceRuntimeStatusDto> {
|
||||
let document_count = self.config_management.engine().registry().descriptors().count();
|
||||
let document_count = u32::try_from(document_count);
|
||||
let document_count = match document_count {
|
||||
@@ -74,6 +84,11 @@ impl crate::AppState {
|
||||
);
|
||||
},
|
||||
};
|
||||
let provider_counts = self.market_price_runtime.provider_counts();
|
||||
let (provider_count, ready_provider_count, unavailable_provider_count) = match provider_counts {
|
||||
std::result::Result::Ok(value) => value,
|
||||
std::result::Result::Err(error) => return std::result::Result::Err(error),
|
||||
};
|
||||
let runtime = self.logging_runtime.lock();
|
||||
let runtime = match runtime {
|
||||
std::result::Result::Ok(value) => value,
|
||||
@@ -85,16 +100,20 @@ impl crate::AppState {
|
||||
},
|
||||
};
|
||||
let _keep_guard_alive = &runtime.guard;
|
||||
let offchain = self.offchain_transport_startup.resolved();
|
||||
return std::result::Result::Ok(crate::RuntimeStatusDto {
|
||||
active_composite_profile: self.offchain_transport_startup.composite_profile_id().to_owned(),
|
||||
let startup = self.market_price_runtime.startup();
|
||||
let offchain = startup.resolved();
|
||||
return std::result::Result::Ok(crate::MarketPriceRuntimeStatusDto {
|
||||
active_composite_profile: startup.composite_profile_id().to_owned(),
|
||||
active_logging_profile: runtime.active_profile_id.clone(),
|
||||
active_offchain_profile: offchain.profile_id().to_owned(),
|
||||
application_version: env!("CARGO_PKG_VERSION").to_owned(),
|
||||
config_document_count: document_count,
|
||||
fallback_logging_active: runtime.fallback_active,
|
||||
shell_phase: "pre.003-offchain-bootstrap".to_owned(),
|
||||
provider_count,
|
||||
ready_provider_count,
|
||||
shell_phase: "pre.004-market-price-runtime".to_owned(),
|
||||
startup_diagnostic: runtime.startup_diagnostic.clone(),
|
||||
unavailable_provider_count,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user