wip: request (and store) debug data in the connection (#6698)
Add in new Debug stubs to the connection
This commit is contained in:
@ -57,6 +57,8 @@ pub struct EngineConnection {
|
|||||||
stats: EngineStats,
|
stats: EngineStats,
|
||||||
|
|
||||||
async_tasks: AsyncTasks,
|
async_tasks: AsyncTasks,
|
||||||
|
|
||||||
|
debug_info: Arc<RwLock<Option<OkWebSocketResponseData>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct TcpRead {
|
pub struct TcpRead {
|
||||||
@ -252,6 +254,8 @@ impl EngineConnection {
|
|||||||
responses: Arc::new(RwLock::new(IndexMap::new())),
|
responses: Arc::new(RwLock::new(IndexMap::new())),
|
||||||
};
|
};
|
||||||
let response_information_cloned = response_information.clone();
|
let response_information_cloned = response_information.clone();
|
||||||
|
let debug_info = Arc::new(RwLock::new(None));
|
||||||
|
let debug_info_cloned = debug_info.clone();
|
||||||
|
|
||||||
let socket_health_tcp_read = socket_health.clone();
|
let socket_health_tcp_read = socket_health.clone();
|
||||||
let tcp_read_handle = tokio::spawn(async move {
|
let tcp_read_handle = tokio::spawn(async move {
|
||||||
@ -338,6 +342,13 @@ impl EngineConnection {
|
|||||||
drop(pe);
|
drop(pe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
WebSocketResponse::Success(SuccessWebSocketResponse {
|
||||||
|
resp: debug @ OkWebSocketResponseData::Debug { .. },
|
||||||
|
..
|
||||||
|
}) => {
|
||||||
|
let mut handle = debug_info_cloned.write().await;
|
||||||
|
*handle = Some(debug.clone());
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -375,6 +386,7 @@ impl EngineConnection {
|
|||||||
session_data,
|
session_data,
|
||||||
stats: Default::default(),
|
stats: Default::default(),
|
||||||
async_tasks: AsyncTasks::new(),
|
async_tasks: AsyncTasks::new(),
|
||||||
|
debug_info,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -414,6 +426,30 @@ impl EngineManager for EngineConnection {
|
|||||||
self.default_planes.clone()
|
self.default_planes.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_debug(&self) -> Option<OkWebSocketResponseData> {
|
||||||
|
self.debug_info.read().await.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_debug(&self) -> Result<(), KclError> {
|
||||||
|
let (tx, rx) = oneshot::channel();
|
||||||
|
|
||||||
|
self.engine_req_tx
|
||||||
|
.send(ToEngineReq {
|
||||||
|
req: WebSocketRequest::Debug {},
|
||||||
|
request_sent: tx,
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.map_err(|e| {
|
||||||
|
KclError::Engine(KclErrorDetails {
|
||||||
|
message: format!("Failed to send debug: {}", e),
|
||||||
|
source_ranges: vec![],
|
||||||
|
})
|
||||||
|
})?;
|
||||||
|
|
||||||
|
let _ = rx.await;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn clear_scene_post_hook(
|
async fn clear_scene_post_hook(
|
||||||
&self,
|
&self,
|
||||||
id_generator: &mut IdGenerator,
|
id_generator: &mut IdGenerator,
|
||||||
|
@ -99,6 +99,14 @@ impl crate::engine::EngineManager for EngineConnection {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_debug(&self) -> Option<OkWebSocketResponseData> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_debug(&self) -> Result<(), KclError> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
async fn inner_fire_modeling_cmd(
|
async fn inner_fire_modeling_cmd(
|
||||||
&self,
|
&self,
|
||||||
id: uuid::Uuid,
|
id: uuid::Uuid,
|
||||||
|
@ -4,7 +4,7 @@ use std::{collections::HashMap, sync::Arc};
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use kcmc::websocket::{WebSocketRequest, WebSocketResponse};
|
use kcmc::websocket::{OkWebSocketResponseData, WebSocketRequest, WebSocketResponse};
|
||||||
use kittycad_modeling_cmds as kcmc;
|
use kittycad_modeling_cmds as kcmc;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
@ -313,6 +313,14 @@ impl crate::engine::EngineManager for EngineConnection {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn fetch_debug(&self) -> Result<(), KclError> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_debug(&self) -> Option<OkWebSocketResponseData> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
async fn inner_fire_modeling_cmd(
|
async fn inner_fire_modeling_cmd(
|
||||||
&self,
|
&self,
|
||||||
id: uuid::Uuid,
|
id: uuid::Uuid,
|
||||||
|
@ -194,6 +194,12 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
|||||||
self.async_tasks().clear().await;
|
self.async_tasks().clear().await;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Fetch debug information from the peer.
|
||||||
|
async fn fetch_debug(&self) -> Result<(), crate::errors::KclError>;
|
||||||
|
|
||||||
|
/// Get any debug information (if requested)
|
||||||
|
async fn get_debug(&self) -> Option<OkWebSocketResponseData>;
|
||||||
|
|
||||||
/// Send a modeling command and do not wait for the response message.
|
/// Send a modeling command and do not wait for the response message.
|
||||||
async fn inner_fire_modeling_cmd(
|
async fn inner_fire_modeling_cmd(
|
||||||
&self,
|
&self,
|
||||||
|
@ -403,6 +403,14 @@ impl kcl_lib::EngineManager for EngineConnection {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_debug(&self) -> Option<OkWebSocketResponseData> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn fetch_debug(&self) -> Result<(), KclError> {
|
||||||
|
unimplemented!();
|
||||||
|
}
|
||||||
|
|
||||||
async fn inner_fire_modeling_cmd(
|
async fn inner_fire_modeling_cmd(
|
||||||
&self,
|
&self,
|
||||||
id: uuid::Uuid,
|
id: uuid::Uuid,
|
||||||
|
Reference in New Issue
Block a user