release: v1.3.1 - Pipeline Queue Integration, OCR Fix, Worker Compatibility
Major Changes: - Pipeline Queue integration completed (internal.file + pipeline.commands) - Fixed old job_worker database compatibility with new command_queue table - Compiled Swift OCR binary (was missing, causing empty OCR results) - Added deep scan functionality through re-scan API Fixes: - Changed CommandJob.id from i32 to i64 for database compatibility - Added UUID generation in create_command (message_id field) - Fixed claim_pending_commands to query queue_name = 'internal.file' - Fixed field mappings: command_id → message_id, job_type → command_type - Added support for 'processing' status in CommandJobStatus Queue System: - internal.file queue: for register/unregister/re-scan commands (job_worker) - pipeline.commands queue: for vectorize/store_asrx/etc commands (pipeline_worker) Documentation: - Added comprehensive queue system documentation - Created M4 workspace status reports - Updated AGENTS.md with queue system details
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
use thiserror::Error;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum ReplayError {
|
||||
#[error("Session not found: {0}")]
|
||||
SessionNotFound(String),
|
||||
|
||||
#[error("Command not found: {0}")]
|
||||
CommandNotFound(i64),
|
||||
|
||||
#[error("Invalid replay type: {0}")]
|
||||
InvalidReplayType(String),
|
||||
|
||||
#[error("Invalid status: {0}")]
|
||||
InvalidStatus(String),
|
||||
|
||||
#[error("Session already running: {0}")]
|
||||
SessionAlreadyRunning(String),
|
||||
|
||||
#[error("Session not running: {0}")]
|
||||
SessionNotRunning(String),
|
||||
|
||||
#[error("No commands to replay")]
|
||||
NoCommandsToReplay,
|
||||
|
||||
#[error("Database error: {0}")]
|
||||
DatabaseError(#[from] sqlx::Error),
|
||||
|
||||
#[error("Worker error: {0}")]
|
||||
WorkerError(String),
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
pub mod error;
|
||||
pub mod store;
|
||||
pub mod types;
|
||||
|
||||
pub use error::ReplayError;
|
||||
pub use store::ReplayStore;
|
||||
pub use types::{
|
||||
CreateReplaySessionRequest, ReplayCommand, ReplayProgress, ReplaySession, ReplayStatus,
|
||||
ReplayType,
|
||||
};
|
||||
|
||||
use sqlx::PgPool;
|
||||
|
||||
pub fn init(db: PgPool) -> ReplayStore {
|
||||
ReplayStore::new(db)
|
||||
}
|
||||
@@ -0,0 +1,441 @@
|
||||
use crate::core::replay::error::ReplayError;
|
||||
use crate::core::replay::types::{
|
||||
CreateReplaySessionRequest, ReplayCommand, ReplaySession, ReplayStatus, ReplayType,
|
||||
};
|
||||
use sqlx::PgPool;
|
||||
use chrono::Utc;
|
||||
|
||||
pub struct ReplayStore {
|
||||
db: PgPool,
|
||||
}
|
||||
|
||||
impl ReplayStore {
|
||||
pub fn new(db: PgPool) -> Self {
|
||||
Self { db }
|
||||
}
|
||||
|
||||
/// 创建 Replay Session
|
||||
pub async fn create_session(
|
||||
&self,
|
||||
req: CreateReplaySessionRequest,
|
||||
user_id: Option<i64>,
|
||||
) -> Result<ReplaySession, ReplayError> {
|
||||
let config = req.config.unwrap_or(serde_json::json!({
|
||||
"concurrency": 5,
|
||||
"delay_ms": 100,
|
||||
"stop_on_error": false,
|
||||
"compare_results": true,
|
||||
"timeout_secs": 300
|
||||
}));
|
||||
|
||||
let row = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO replay_sessions (session_name, replay_type, source_filter, config, user_id)
|
||||
VALUES ($1, $2, $3, $4, $5)
|
||||
RETURNING
|
||||
id, session_id, session_name, replay_type, source_filter, config, status,
|
||||
total_commands, processed_commands, succeeded_commands, failed_commands, skipped_commands,
|
||||
comparison_results, started_at, completed_at, duration_secs, error_message,
|
||||
created_at, updated_at, user_id
|
||||
"#,
|
||||
req.session_name,
|
||||
req.replay_type.as_str(),
|
||||
req.source_filter.to_string(),
|
||||
config.to_string(),
|
||||
user_id,
|
||||
)
|
||||
.fetch_one(&self.db)
|
||||
.await?;
|
||||
|
||||
Ok(ReplaySession {
|
||||
id: row.id,
|
||||
session_id: row.session_id,
|
||||
session_name: row.session_name,
|
||||
replay_type: ReplayType::from_str(&row.replay_type).unwrap(),
|
||||
source_filter: serde_json::from_str(&row.source_filter).unwrap_or_default(),
|
||||
config: serde_json::from_str(&row.config).unwrap_or_default(),
|
||||
status: ReplayStatus::from_str(&row.status).unwrap(),
|
||||
total_commands: row.total_commands,
|
||||
processed_commands: row.processed_commands,
|
||||
succeeded_commands: row.succeeded_commands,
|
||||
failed_commands: row.failed_commands,
|
||||
skipped_commands: row.skipped_commands,
|
||||
comparison_results: serde_json::from_str(&row.comparison_results).unwrap_or_default(),
|
||||
started_at: row.started_at,
|
||||
completed_at: row.completed_at,
|
||||
duration_secs: row.duration_secs,
|
||||
error_message: row.error_message,
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at,
|
||||
user_id: row.user_id,
|
||||
})
|
||||
}
|
||||
|
||||
/// 获取 Session
|
||||
pub async fn get_session(&self, session_id: &str) -> Result<Option<ReplaySession>, ReplayError> {
|
||||
let row = sqlx::query!(
|
||||
r#"
|
||||
SELECT
|
||||
id, session_id, session_name, replay_type, source_filter, config, status,
|
||||
total_commands, processed_commands, succeeded_commands, failed_commands, skipped_commands,
|
||||
comparison_results, started_at, completed_at, duration_secs, error_message,
|
||||
created_at, updated_at, user_id
|
||||
FROM replay_sessions
|
||||
WHERE session_id = $1
|
||||
"#,
|
||||
session_id,
|
||||
)
|
||||
.fetch_optional(&self.db)
|
||||
.await?;
|
||||
|
||||
match row {
|
||||
Some(row) => Ok(Some(ReplaySession {
|
||||
id: row.id,
|
||||
session_id: row.session_id,
|
||||
session_name: row.session_name,
|
||||
replay_type: ReplayType::from_str(&row.replay_type).unwrap(),
|
||||
source_filter: serde_json::from_str(&row.source_filter).unwrap_or_default(),
|
||||
config: serde_json::from_str(&row.config).unwrap_or_default(),
|
||||
status: ReplayStatus::from_str(&row.status).unwrap(),
|
||||
total_commands: row.total_commands,
|
||||
processed_commands: row.processed_commands,
|
||||
succeeded_commands: row.succeeded_commands,
|
||||
failed_commands: row.failed_commands,
|
||||
skipped_commands: row.skipped_commands,
|
||||
comparison_results: serde_json::from_str(&row.comparison_results).unwrap_or_default(),
|
||||
started_at: row.started_at,
|
||||
completed_at: row.completed_at,
|
||||
duration_secs: row.duration_secs,
|
||||
error_message: row.error_message,
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at,
|
||||
user_id: row.user_id,
|
||||
})),
|
||||
None => Ok(None),
|
||||
}
|
||||
}
|
||||
|
||||
/// 更新 Session 状态
|
||||
pub async fn update_session_status(
|
||||
&self,
|
||||
session_id: &str,
|
||||
status: ReplayStatus,
|
||||
error_message: Option<&str>,
|
||||
) -> Result<(), ReplayError> {
|
||||
let now = Utc::now();
|
||||
|
||||
match status {
|
||||
ReplayStatus::Running => {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE replay_sessions
|
||||
SET status = $2, started_at = $3
|
||||
WHERE session_id = $1
|
||||
"#,
|
||||
session_id,
|
||||
status.as_str(),
|
||||
now,
|
||||
)
|
||||
.execute(&self.db)
|
||||
.await?;
|
||||
}
|
||||
ReplayStatus::Completed | ReplayStatus::Failed | ReplayStatus::Cancelled => {
|
||||
// 计算持续时间
|
||||
let session = self.get_session(session_id).await?.ok_or_else(|| {
|
||||
ReplayError::SessionNotFound(session_id.to_string())
|
||||
})?;
|
||||
|
||||
let duration_secs = session.started_at.map(|start| {
|
||||
(now - start).num_seconds() as f64
|
||||
});
|
||||
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE replay_sessions
|
||||
SET status = $2, completed_at = $3, duration_secs = $4, error_message = $5
|
||||
WHERE session_id = $1
|
||||
"#,
|
||||
session_id,
|
||||
status.as_str(),
|
||||
now,
|
||||
duration_secs,
|
||||
error_message,
|
||||
)
|
||||
.execute(&self.db)
|
||||
.await?;
|
||||
}
|
||||
_ => {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE replay_sessions
|
||||
SET status = $2
|
||||
WHERE session_id = $1
|
||||
"#,
|
||||
session_id,
|
||||
status.as_str(),
|
||||
)
|
||||
.execute(&self.db)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 更新 Session 统计
|
||||
pub async fn update_session_stats(
|
||||
&self,
|
||||
session_id: &str,
|
||||
processed: i32,
|
||||
succeeded: i32,
|
||||
failed: i32,
|
||||
skipped: i32,
|
||||
) -> Result<(), ReplayError> {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE replay_sessions
|
||||
SET
|
||||
processed_commands = $2,
|
||||
succeeded_commands = $3,
|
||||
failed_commands = $4,
|
||||
skipped_commands = $5
|
||||
WHERE session_id = $1
|
||||
"#,
|
||||
session_id,
|
||||
processed,
|
||||
succeeded,
|
||||
failed,
|
||||
skipped,
|
||||
)
|
||||
.execute(&self.db)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 创建 Replay Command
|
||||
pub async fn create_replay_command(
|
||||
&self,
|
||||
session_id: &str,
|
||||
original_command_id: &str,
|
||||
original_job_type: &str,
|
||||
original_file_path: Option<&str>,
|
||||
original_file_uuid: Option<&str>,
|
||||
original_payload: Option<serde_json::Value>,
|
||||
) -> Result<ReplayCommand, ReplayError> {
|
||||
let row = sqlx::query!(
|
||||
r#"
|
||||
INSERT INTO replay_commands
|
||||
(session_id, original_command_id, original_job_type, original_file_path,
|
||||
original_file_uuid, original_payload, status)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, 'pending')
|
||||
RETURNING
|
||||
id, session_id, original_command_id, replay_command_id, status,
|
||||
original_job_type, original_file_path, original_file_uuid, original_payload,
|
||||
original_result, replay_result, comparison_status, differences,
|
||||
original_duration_secs, replay_duration_secs, error_message, retry_count,
|
||||
started_at, completed_at, created_at
|
||||
"#,
|
||||
session_id,
|
||||
original_command_id,
|
||||
original_job_type,
|
||||
original_file_path,
|
||||
original_file_uuid,
|
||||
original_payload.map(|p| p.to_string()),
|
||||
)
|
||||
.fetch_one(&self.db)
|
||||
.await?;
|
||||
|
||||
Ok(ReplayCommand {
|
||||
id: row.id,
|
||||
session_id: row.session_id,
|
||||
original_command_id: row.original_command_id,
|
||||
replay_command_id: row.replay_command_id,
|
||||
status: row.status,
|
||||
original_job_type: row.original_job_type,
|
||||
original_file_path: row.original_file_path,
|
||||
original_file_uuid: row.original_file_uuid,
|
||||
original_payload: row.original_payload.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
original_result: row.original_result.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
replay_result: row.replay_result.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
comparison_status: row.comparison_status,
|
||||
differences: row.differences.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
original_duration_secs: row.original_duration_secs,
|
||||
replay_duration_secs: row.replay_duration_secs,
|
||||
error_message: row.error_message,
|
||||
retry_count: row.retry_count,
|
||||
started_at: row.started_at,
|
||||
completed_at: row.completed_at,
|
||||
created_at: row.created_at,
|
||||
})
|
||||
}
|
||||
|
||||
/// 获取待处理的 Replay Commands
|
||||
pub async fn get_pending_commands(
|
||||
&self,
|
||||
session_id: &str,
|
||||
limit: i32,
|
||||
) -> Result<Vec<ReplayCommand>, ReplayError> {
|
||||
let rows = sqlx::query!(
|
||||
r#"
|
||||
SELECT
|
||||
id, session_id, original_command_id, replay_command_id, status,
|
||||
original_job_type, original_file_path, original_file_uuid, original_payload,
|
||||
original_result, replay_result, comparison_status, differences,
|
||||
original_duration_secs, replay_duration_secs, error_message, retry_count,
|
||||
started_at, completed_at, created_at
|
||||
FROM replay_commands
|
||||
WHERE session_id = $1 AND status = 'pending'
|
||||
ORDER BY id ASC
|
||||
LIMIT $2
|
||||
FOR UPDATE SKIP LOCKED
|
||||
"#,
|
||||
session_id,
|
||||
limit,
|
||||
)
|
||||
.fetch_all(&self.db)
|
||||
.await?;
|
||||
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(|row| ReplayCommand {
|
||||
id: row.id,
|
||||
session_id: row.session_id,
|
||||
original_command_id: row.original_command_id,
|
||||
replay_command_id: row.replay_command_id,
|
||||
status: row.status,
|
||||
original_job_type: row.original_job_type,
|
||||
original_file_path: row.original_file_path,
|
||||
original_file_uuid: row.original_file_uuid,
|
||||
original_payload: row.original_payload.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
original_result: row.original_result.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
replay_result: row.replay_result.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
comparison_status: row.comparison_status,
|
||||
differences: row.differences.and_then(|s| serde_json::from_str(&s).ok()),
|
||||
original_duration_secs: row.original_duration_secs,
|
||||
replay_duration_secs: row.replay_duration_secs,
|
||||
error_message: row.error_message,
|
||||
retry_count: row.retry_count,
|
||||
started_at: row.started_at,
|
||||
completed_at: row.completed_at,
|
||||
created_at: row.created_at,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
|
||||
/// 更新 Replay Command 状态
|
||||
pub async fn update_command_status(
|
||||
&self,
|
||||
command_id: i64,
|
||||
status: &str,
|
||||
replay_command_id: Option<&str>,
|
||||
replay_result: Option<serde_json::Value>,
|
||||
comparison_status: Option<&str>,
|
||||
differences: Option<serde_json::Value>,
|
||||
error_message: Option<&str>,
|
||||
) -> Result<(), ReplayError> {
|
||||
let now = Utc::now();
|
||||
|
||||
sqlx::query!(
|
||||
r#"
|
||||
UPDATE replay_commands
|
||||
SET
|
||||
status = $2,
|
||||
replay_command_id = COALESCE($3, replay_command_id),
|
||||
replay_result = COALESCE($4, replay_result),
|
||||
comparison_status = COALESCE($5, comparison_status),
|
||||
differences = COALESCE($6, differences),
|
||||
error_message = COALESCE($7, error_message),
|
||||
completed_at = $8
|
||||
WHERE id = $1
|
||||
"#,
|
||||
command_id,
|
||||
status,
|
||||
replay_command_id,
|
||||
replay_result.map(|r| r.to_string()),
|
||||
comparison_status,
|
||||
differences.map(|d| d.to_string()),
|
||||
error_message,
|
||||
now,
|
||||
)
|
||||
.execute(&self.db)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// 列出 Sessions
|
||||
pub async fn list_sessions(
|
||||
&self,
|
||||
status: Option<&str>,
|
||||
limit: i32,
|
||||
offset: i32,
|
||||
) -> Result<Vec<ReplaySession>, ReplayError> {
|
||||
let rows = match status {
|
||||
Some(s) => {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
SELECT
|
||||
id, session_id, session_name, replay_type, source_filter, config, status,
|
||||
total_commands, processed_commands, succeeded_commands, failed_commands, skipped_commands,
|
||||
comparison_results, started_at, completed_at, duration_secs, error_message,
|
||||
created_at, updated_at, user_id
|
||||
FROM replay_sessions
|
||||
WHERE status = $1
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $2 OFFSET $3
|
||||
"#,
|
||||
s,
|
||||
limit,
|
||||
offset,
|
||||
)
|
||||
.fetch_all(&self.db)
|
||||
.await?
|
||||
}
|
||||
None => {
|
||||
sqlx::query!(
|
||||
r#"
|
||||
SELECT
|
||||
id, session_id, session_name, replay_type, source_filter, config, status,
|
||||
total_commands, processed_commands, succeeded_commands, failed_commands, skipped_commands,
|
||||
comparison_results, started_at, completed_at, duration_secs, error_message,
|
||||
created_at, updated_at, user_id
|
||||
FROM replay_sessions
|
||||
ORDER BY created_at DESC
|
||||
LIMIT $1 OFFSET $2
|
||||
"#,
|
||||
limit,
|
||||
offset,
|
||||
)
|
||||
.fetch_all(&self.db)
|
||||
.await?
|
||||
}
|
||||
};
|
||||
|
||||
Ok(rows
|
||||
.into_iter()
|
||||
.map(|row| ReplaySession {
|
||||
id: row.id,
|
||||
session_id: row.session_id,
|
||||
session_name: row.session_name,
|
||||
replay_type: ReplayType::from_str(&row.replay_type).unwrap(),
|
||||
source_filter: serde_json::from_str(&row.source_filter).unwrap_or_default(),
|
||||
config: serde_json::from_str(&row.config).unwrap_or_default(),
|
||||
status: ReplayStatus::from_str(&row.status).unwrap(),
|
||||
total_commands: row.total_commands,
|
||||
processed_commands: row.processed_commands,
|
||||
succeeded_commands: row.succeeded_commands,
|
||||
failed_commands: row.failed_commands,
|
||||
skipped_commands: row.skipped_commands,
|
||||
comparison_results: serde_json::from_str(&row.comparison_results).unwrap_or_default(),
|
||||
started_at: row.started_at,
|
||||
completed_at: row.completed_at,
|
||||
duration_secs: row.duration_secs,
|
||||
error_message: row.error_message,
|
||||
created_at: row.created_at,
|
||||
updated_at: row.updated_at,
|
||||
user_id: row.user_id,
|
||||
})
|
||||
.collect())
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value as JsonValue;
|
||||
|
||||
/// Replay 类型
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ReplayType {
|
||||
/// 重放成功命令(验证幂等性)
|
||||
Success,
|
||||
/// 重放失败命令(测试容错)
|
||||
Failed,
|
||||
/// 批量重放(压力测试)
|
||||
Batch,
|
||||
/// 场景回放(测试特定场景)
|
||||
Scenario,
|
||||
}
|
||||
|
||||
impl ReplayType {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
ReplayType::Success => "success",
|
||||
ReplayType::Failed => "failed",
|
||||
ReplayType::Batch => "batch",
|
||||
ReplayType::Scenario => "scenario",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(s: &str) -> Option<Self> {
|
||||
match s {
|
||||
"success" => Some(ReplayType::Success),
|
||||
"failed" => Some(ReplayType::Failed),
|
||||
"batch" => Some(ReplayType::Batch),
|
||||
"scenario" => Some(ReplayType::Scenario),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Replay Session 状态
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub enum ReplayStatus {
|
||||
Pending,
|
||||
Running,
|
||||
Paused,
|
||||
Completed,
|
||||
Failed,
|
||||
Cancelled,
|
||||
}
|
||||
|
||||
impl ReplayStatus {
|
||||
pub fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
ReplayStatus::Pending => "pending",
|
||||
ReplayStatus::Running => "running",
|
||||
ReplayStatus::Paused => "paused",
|
||||
ReplayStatus::Completed => "completed",
|
||||
ReplayStatus::Failed => "failed",
|
||||
ReplayStatus::Cancelled => "cancelled",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_str(s: &str) -> Option<Self> {
|
||||
match s {
|
||||
"pending" => Some(ReplayStatus::Pending),
|
||||
"running" => Some(ReplayStatus::Running),
|
||||
"paused" => Some(ReplayStatus::Paused),
|
||||
"completed" => Some(ReplayStatus::Completed),
|
||||
"failed" => Some(ReplayStatus::Failed),
|
||||
"cancelled" => Some(ReplayStatus::Cancelled),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Replay Session
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReplaySession {
|
||||
pub id: i64,
|
||||
pub session_id: String,
|
||||
pub session_name: Option<String>,
|
||||
pub replay_type: ReplayType,
|
||||
pub source_filter: JsonValue,
|
||||
pub config: JsonValue,
|
||||
pub status: ReplayStatus,
|
||||
|
||||
pub total_commands: i32,
|
||||
pub processed_commands: i32,
|
||||
pub succeeded_commands: i32,
|
||||
pub failed_commands: i32,
|
||||
pub skipped_commands: i32,
|
||||
|
||||
pub comparison_results: JsonValue,
|
||||
|
||||
pub started_at: Option<DateTime<Utc>>,
|
||||
pub completed_at: Option<DateTime<Utc>>,
|
||||
pub duration_secs: Option<f64>,
|
||||
|
||||
pub error_message: Option<String>,
|
||||
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
|
||||
pub user_id: Option<i64>,
|
||||
}
|
||||
|
||||
/// 创建 Replay Session 请求
|
||||
#[derive(Debug, Clone, Deserialize)]
|
||||
pub struct CreateReplaySessionRequest {
|
||||
pub session_name: Option<String>,
|
||||
pub replay_type: ReplayType,
|
||||
pub source_filter: JsonValue,
|
||||
pub config: Option<JsonValue>,
|
||||
}
|
||||
|
||||
/// Replay Session 进度
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ReplayProgress {
|
||||
pub session_id: String,
|
||||
pub status: ReplayStatus,
|
||||
pub progress: ReplayProgressInfo,
|
||||
pub performance: Option<ReplayPerformance>,
|
||||
pub comparison: Option<ReplayComparison>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ReplayProgressInfo {
|
||||
pub total: i32,
|
||||
pub processed: i32,
|
||||
pub succeeded: i32,
|
||||
pub failed: i32,
|
||||
pub percentage: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ReplayPerformance {
|
||||
pub started_at: DateTime<Utc>,
|
||||
pub elapsed_secs: f64,
|
||||
pub avg_command_time_secs: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct ReplayComparison {
|
||||
pub match_count: i32,
|
||||
pub mismatch_count: i32,
|
||||
pub error_count: i32,
|
||||
pub match_rate: f64,
|
||||
}
|
||||
|
||||
/// Replay Command
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ReplayCommand {
|
||||
pub id: i64,
|
||||
pub session_id: String,
|
||||
pub original_command_id: String,
|
||||
pub replay_command_id: Option<String>,
|
||||
|
||||
pub status: String,
|
||||
|
||||
pub original_job_type: Option<String>,
|
||||
pub original_file_path: Option<String>,
|
||||
pub original_file_uuid: Option<String>,
|
||||
pub original_payload: Option<JsonValue>,
|
||||
|
||||
pub original_result: Option<JsonValue>,
|
||||
pub replay_result: Option<JsonValue>,
|
||||
pub comparison_status: Option<String>,
|
||||
pub differences: Option<JsonValue>,
|
||||
|
||||
pub original_duration_secs: Option<f64>,
|
||||
pub replay_duration_secs: Option<f64>,
|
||||
|
||||
pub error_message: Option<String>,
|
||||
pub retry_count: i32,
|
||||
|
||||
pub started_at: Option<DateTime<Utc>>,
|
||||
pub completed_at: Option<DateTime<Utc>>,
|
||||
pub created_at: DateTime<Utc>,
|
||||
}
|
||||
Reference in New Issue
Block a user