0.7.22
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#![warn(missing_docs)]
|
||||
|
||||
mod demo_http;
|
||||
mod demo_pipeline;
|
||||
mod demo_ws;
|
||||
mod demo_ws_manager;
|
||||
mod splash;
|
||||
@@ -36,16 +37,18 @@ impl KbWsRuntimeState {
|
||||
/// Shared application state stored inside Tauri.
|
||||
struct KbAppState {
|
||||
config: kb_lib::KbConfig,
|
||||
database: std::sync::Arc<kb_lib::KbDatabase>,
|
||||
ws_runtime: tokio::sync::Mutex<KbWsRuntimeState>,
|
||||
demo_ws_runtime: std::sync::Arc<tokio::sync::Mutex<crate::demo_ws::KbDemoWsRuntimeState>>,
|
||||
demo_ws_manager_runtime: std::sync::Arc<tokio::sync::Mutex<crate::demo_ws_manager::KbDemoWsManagerRuntimeState>>,
|
||||
demo_ws_manager_runtime:
|
||||
std::sync::Arc<tokio::sync::Mutex<crate::demo_ws_manager::KbDemoWsManagerRuntimeState>>,
|
||||
ws_manager: std::sync::Arc<kb_lib::WsManager>,
|
||||
http_pool: kb_lib::HttpEndpointPool,
|
||||
}
|
||||
|
||||
/// Runs the desktop application.
|
||||
#[cfg_attr(mobile, tauri::mobile_entry_point)]
|
||||
pub fn run() {
|
||||
pub async fn run() -> Result<(), kb_lib::KbError> {
|
||||
let config_path = kb_lib::KbConfig::default_path();
|
||||
let config_result = kb_lib::KbConfig::load_from_path(&config_path);
|
||||
let config = match config_result {
|
||||
@@ -56,20 +59,20 @@ pub fn run() {
|
||||
config_path.display(),
|
||||
error
|
||||
);
|
||||
return;
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
let prepare_result = config.prepare_filesystem();
|
||||
if let Err(error) = prepare_result {
|
||||
eprintln!("kb_app filesystem preparation error: {error}");
|
||||
return;
|
||||
return Err(error);
|
||||
}
|
||||
let tracing_guard_result = kb_lib::init_tracing(&config.logging);
|
||||
let _tracing_guard = match tracing_guard_result {
|
||||
Ok(guard) => guard,
|
||||
Err(error) => {
|
||||
eprintln!("kb_app tracing initialization error: {error}");
|
||||
return;
|
||||
return Err(error);
|
||||
}
|
||||
};
|
||||
tracing::info!(
|
||||
@@ -77,6 +80,11 @@ pub fn run() {
|
||||
environment = %config.app.environment,
|
||||
"starting desktop application"
|
||||
);
|
||||
let database_result = kb_lib::KbDatabase::connect_and_initialize(&config.database).await;
|
||||
let database = match database_result {
|
||||
Ok(database) => database,
|
||||
Err(error) => return Err(error),
|
||||
};
|
||||
let http_pool_result = kb_lib::HttpEndpointPool::from_config(&config);
|
||||
let http_pool = match http_pool_result {
|
||||
Ok(http_pool) => http_pool,
|
||||
@@ -95,6 +103,7 @@ pub fn run() {
|
||||
};
|
||||
let app_state = KbAppState {
|
||||
config: config.clone(),
|
||||
database: std::sync::Arc::new(database),
|
||||
ws_runtime: tokio::sync::Mutex::new(KbWsRuntimeState::new()),
|
||||
demo_ws_runtime: std::sync::Arc::new(tokio::sync::Mutex::new(
|
||||
crate::demo_ws::KbDemoWsRuntimeState::new(),
|
||||
@@ -128,6 +137,11 @@ pub fn run() {
|
||||
crate::demo_ws_manager::demo_ws_manager_stop_all,
|
||||
crate::demo_ws_manager::demo_ws_manager_start_role,
|
||||
crate::demo_ws_manager::demo_ws_manager_stop_role,
|
||||
crate::demo_pipeline::open_demo_pipeline_window,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_signature,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_token_mint,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_pair_id,
|
||||
crate::demo_pipeline::demo_pipeline_inspect_pool_address,
|
||||
]);
|
||||
tauri_builder = tauri_builder.plugin(tracing_builder.build::<tauri::Wry>());
|
||||
tauri_builder = tauri_builder.setup(|app| {
|
||||
@@ -202,7 +216,11 @@ pub fn run() {
|
||||
let run_result = tauri_builder.run(tauri::generate_context!());
|
||||
if let Err(error) = run_result {
|
||||
tracing::error!("error while running tauri application: {error:?}");
|
||||
return Err(kb_lib::KbError::InvalidState(format!(
|
||||
"error while running tauri application: {error:?}"
|
||||
)));
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn emit_splash_order(
|
||||
|
||||
Reference in New Issue
Block a user