fix: cargo check --lib error
This commit is contained in:
parent
60221bd457
commit
04ba451762
|
|
@ -4,8 +4,8 @@
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use std::collections::{HashMap, VecDeque, BTreeMap};
|
use std::collections::{HashMap, VecDeque, BTreeMap};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration};
|
||||||
use tokio::sync::{RwLock, Mutex, mpsc, broadcast};
|
use tokio::sync::{RwLock, broadcast};
|
||||||
use tracing::{info, warn, error, debug};
|
use tracing::{info, warn, error, debug};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
|
|
|
||||||
|
|
@ -5,14 +5,10 @@ use anyhow::{Result, anyhow};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use tokio::sync::{RwLock, mpsc, broadcast};
|
use tokio::sync::{RwLock, broadcast};
|
||||||
use tracing::{info, warn, error, debug};
|
use tracing::{info, warn, error};
|
||||||
|
|
||||||
use comfyui_sdk::types::events::{ExecutionProgress, ExecutionResult, ExecutionError, ExecutionCallbacks};
|
|
||||||
use comfyui_sdk::client::websocket_client::WebSocketClient;
|
|
||||||
|
|
||||||
use crate::business::services::comfyui_manager::ComfyUIManager;
|
use crate::business::services::comfyui_manager::ComfyUIManager;
|
||||||
use crate::data::models::comfyui::{ExecutionModel, ExecutionStatus};
|
|
||||||
use crate::data::repositories::comfyui_repository::ComfyUIRepository;
|
use crate::data::repositories::comfyui_repository::ComfyUIRepository;
|
||||||
|
|
||||||
/// 实时事件类型
|
/// 实时事件类型
|
||||||
|
|
@ -420,7 +416,6 @@ impl RealtimeMonitor {
|
||||||
event_subscribers: self.event_sender.receiver_count(),
|
event_subscribers: self.event_sender.receiver_count(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 监控统计信息
|
/// 监控统计信息
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,17 @@
|
||||||
//! 增强版实时监控服务
|
//! 增强版实时监控服务
|
||||||
//! 基于 ComfyUI SDK WebSocket 客户端的完整实时通信实现
|
//! 基于 ComfyUI SDK WebSocket 客户端的完整实时通信实现
|
||||||
|
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{anyhow, Result};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
use std::time::Duration;
|
||||||
use tokio::sync::{RwLock, mpsc, broadcast, Mutex};
|
use tokio::sync::{broadcast, Mutex, RwLock};
|
||||||
use tokio::time::{sleep, timeout, interval};
|
use tokio::time::{interval, sleep};
|
||||||
use tracing::{info, warn, error, debug};
|
use tracing::{debug, error, info, warn};
|
||||||
use serde::{Serialize, Deserialize};
|
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
use crate::business::services::tauri_event_emitter::TauriEventEmitter;
|
|
||||||
use crate::data::models::comfyui::{ExecutionModel, ExecutionStatus};
|
|
||||||
use crate::data::repositories::comfyui_repository::ComfyUIRepository;
|
|
||||||
use crate::business::services::comfyui_manager::ComfyUIManager;
|
use crate::business::services::comfyui_manager::ComfyUIManager;
|
||||||
|
use crate::data::repositories::comfyui_repository::ComfyUIRepository;
|
||||||
use comfyui_sdk::WebSocketClient;
|
use comfyui_sdk::WebSocketClient;
|
||||||
|
|
||||||
/// 实时事件类型
|
/// 实时事件类型
|
||||||
|
|
@ -259,7 +256,9 @@ impl RealtimeMonitorV2 {
|
||||||
prompt_execution_map.clone(),
|
prompt_execution_map.clone(),
|
||||||
event_stats.clone(),
|
event_stats.clone(),
|
||||||
config.clone(),
|
config.clone(),
|
||||||
).await {
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
info!("WebSocket 连接成功");
|
info!("WebSocket 连接成功");
|
||||||
reconnect_attempts = 0;
|
reconnect_attempts = 0;
|
||||||
|
|
@ -270,12 +269,17 @@ impl RealtimeMonitorV2 {
|
||||||
reconnect_attempts += 1;
|
reconnect_attempts += 1;
|
||||||
|
|
||||||
if config.auto_reconnect {
|
if config.auto_reconnect {
|
||||||
warn!("将在 {:?} 后重试连接 (第 {} 次)", reconnect_interval, reconnect_attempts);
|
warn!(
|
||||||
|
"将在 {:?} 后重试连接 (第 {} 次)",
|
||||||
|
reconnect_interval, reconnect_attempts
|
||||||
|
);
|
||||||
sleep(reconnect_interval).await;
|
sleep(reconnect_interval).await;
|
||||||
|
|
||||||
// 指数退避
|
// 指数退避
|
||||||
reconnect_interval = std::cmp::min(
|
reconnect_interval = std::cmp::min(
|
||||||
Duration::from_millis((reconnect_interval.as_millis() as f64 * 1.5) as u64),
|
Duration::from_millis(
|
||||||
|
(reconnect_interval.as_millis() as f64 * 1.5) as u64,
|
||||||
|
),
|
||||||
config.max_reconnect_interval,
|
config.max_reconnect_interval,
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -385,11 +389,13 @@ impl RealtimeMonitorV2 {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送连接状态变化事件
|
// 发送连接状态变化事件
|
||||||
let _ = self.emit_event(RealtimeEventV2::ConnectionChanged {
|
let _ = self
|
||||||
connected: false,
|
.emit_event(RealtimeEventV2::ConnectionChanged {
|
||||||
message: "实时监控服务已停止".to_string(),
|
connected: false,
|
||||||
timestamp: chrono::Utc::now().to_rfc3339(),
|
message: "实时监控服务已停止".to_string(),
|
||||||
}).await;
|
timestamp: chrono::Utc::now().to_rfc3339(),
|
||||||
|
})
|
||||||
|
.await;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
@ -460,12 +466,16 @@ impl RealtimeMonitorV2 {
|
||||||
RealtimeEventV2::SystemStatusUpdated { .. } => "system_status_updated",
|
RealtimeEventV2::SystemStatusUpdated { .. } => "system_status_updated",
|
||||||
};
|
};
|
||||||
|
|
||||||
*stats.events_by_type.entry(event_type.to_string()).or_insert(0) += 1;
|
*stats
|
||||||
|
.events_by_type
|
||||||
|
.entry(event_type.to_string())
|
||||||
|
.or_insert(0) += 1;
|
||||||
|
|
||||||
// 计算每分钟事件数
|
// 计算每分钟事件数
|
||||||
let elapsed = chrono::Utc::now().signed_duration_since(stats.start_time);
|
let elapsed = chrono::Utc::now().signed_duration_since(stats.start_time);
|
||||||
if elapsed.num_seconds() > 0 {
|
if elapsed.num_seconds() > 0 {
|
||||||
stats.events_per_minute = stats.total_events as f64 / (elapsed.num_seconds() as f64 / 60.0);
|
stats.events_per_minute =
|
||||||
|
stats.total_events as f64 / (elapsed.num_seconds() as f64 / 60.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -499,8 +509,6 @@ impl RealtimeMonitorV2 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// 监控统计信息
|
/// 监控统计信息
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct MonitorStats {
|
pub struct MonitorStats {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result, anyhow};
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::RwLock;
|
use tokio::sync::RwLock;
|
||||||
use tracing::{info, warn, error, debug};
|
use tracing::{info, warn};
|
||||||
|
|
||||||
use crate::business::services::{
|
use crate::business::services::{
|
||||||
comfyui_manager::ComfyUIManager,
|
comfyui_manager::ComfyUIManager,
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,9 @@
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tauri::{AppHandle, Manager};
|
use tauri::{AppHandle};
|
||||||
use tokio::sync::broadcast;
|
use tokio::sync::broadcast;
|
||||||
use tracing::{info, warn, error, debug};
|
use tracing::{info, error, debug};
|
||||||
use serde::{Serialize, Deserialize};
|
use serde::{Serialize, Deserialize};
|
||||||
|
|
||||||
use crate::business::services::realtime_monitor_v2::{RealtimeEventV2, EventSubscriber};
|
use crate::business::services::realtime_monitor_v2::{RealtimeEventV2, EventSubscriber};
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
//! WebSocket 消息处理器
|
//! WebSocket 消息处理器
|
||||||
//! 专门处理 ComfyUI WebSocket 消息的解析和事件转换
|
//! 专门处理 ComfyUI WebSocket 消息的解析和事件转换
|
||||||
|
|
||||||
use anyhow::{Result, anyhow};
|
use anyhow::{Result};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use tokio::sync::{RwLock, broadcast};
|
use tokio::sync::{RwLock, broadcast};
|
||||||
use tracing::{info, warn, error, debug};
|
use tracing::{debug};
|
||||||
use serde_json::Value;
|
use serde_json::Value;
|
||||||
|
|
||||||
use crate::business::services::realtime_monitor_v2::RealtimeEventV2;
|
use crate::business::services::realtime_monitor_v2::RealtimeEventV2;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ use regex::Regex;
|
||||||
use crate::data::models::outfit_photo_generation::{
|
use crate::data::models::outfit_photo_generation::{
|
||||||
ExecuteWorkflowRequest, ExecuteWorkflowResponse, NodeMapping, WorkflowNodeReplacement
|
ExecuteWorkflowRequest, ExecuteWorkflowResponse, NodeMapping, WorkflowNodeReplacement
|
||||||
};
|
};
|
||||||
use crate::data::models::workflow_template::{WorkflowTemplate, WorkflowType};
|
use crate::data::models::workflow_template::{WorkflowTemplate};
|
||||||
use crate::data::models::workflow_execution_record::{
|
use crate::data::models::workflow_execution_record::{
|
||||||
CreateExecutionRecordRequest, WorkflowExecutionRecord
|
CreateExecutionRecordRequest, WorkflowExecutionRecord
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue