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