feat: add job worker and duplicate registration check

Job Worker System:
- Add polling-based job worker (max 2 concurrent processors)
- Create monitor_jobs records when videos are registered
- Link videos.job_id to monitor_jobs
- Fix type mismatches (i32 vs i64) for database IDs

Duplicate Registration:
- Check if video already exists before registering
- Return existing video info with already_exists: true
- Use canonical path for UUID computation

USER_DATA_ROOT Configuration:
- Add MOMENTRY_USER_DATA_ROOT environment variable
- UUID computed from relative path (username/filename)
- Ensures consistent UUIDs when data root changes
This commit is contained in:
accusys
2026-03-25 02:50:31 +08:00
parent cd0f952aeb
commit 12a7b59232
9 changed files with 3669 additions and 229 deletions
+2111 -103
View File
File diff suppressed because it is too large Load Diff
+4 -4
View File
@@ -336,7 +336,7 @@ impl RedisClient {
pub async fn update_worker_job_status(
&self,
uuid: &str,
job_id: i64,
job_id: i32,
status: &str,
current_processor: Option<&str>,
progress: i32,
@@ -401,7 +401,7 @@ impl RedisClient {
}
let status: String = conn.hget(&key, "status").await?;
let job_id: i64 = conn.hget(&key, "job_id").await?;
let job_id: i32 = conn.hget(&key, "job_id").await?;
let current_processor: String = conn.hget(&key, "current_processor").await?;
let progress_current: i32 = conn.hget(&key, "progress_current").await?;
let progress_total: i32 = conn.hget(&key, "progress_total").await?;
@@ -538,7 +538,7 @@ pub struct AnomalyAlertMessage {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkerJobStatus {
pub uuid: String,
pub job_id: i64,
pub job_id: i32,
pub status: String,
pub current_processor: String,
pub progress_current: i32,
@@ -549,7 +549,7 @@ pub struct WorkerJobStatus {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct WorkerJobInfo {
pub uuid: String,
pub job_id: i64,
pub job_id: i32,
pub status: String,
pub progress_current: i32,
pub progress_total: i32,