feat: add processor state machine and alert mechanism

- Add ProcessorJobStatus enum (8 states: Idle/Waiting/Ready/Pending/Running/Completed/Failed/Skipped)
- Add processor_alerts table (migrations/034)
- Add emit_processor_alert() to redis_client.rs
- Add ConditionResult enum + check_dependencies() to job_worker.rs
This commit is contained in:
Accusys
2026-05-30 10:03:49 +08:00
parent 08167d73b2
commit 0d58a738a1
4 changed files with 475 additions and 221 deletions

View File

@@ -0,0 +1,23 @@
-- Migration: 034_processor_state_machine
-- Purpose: Add processor_alerts table for State Machine alert mechanism
-- Date: 2026-05-30
-- Create processor_alerts table
CREATE TABLE IF NOT EXISTS processor_alerts (
id SERIAL PRIMARY KEY,
file_uuid VARCHAR(32),
processor_type VARCHAR(32) NOT NULL,
alert_type VARCHAR(32) NOT NULL,
message TEXT,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
-- Create indexes for efficient querying
CREATE INDEX IF NOT EXISTS idx_alerts_file_uuid ON processor_alerts(file_uuid);
CREATE INDEX IF NOT EXISTS idx_alerts_processor_type ON processor_alerts(processor_type);
CREATE INDEX IF NOT EXISTS idx_alerts_alert_type ON processor_alerts(alert_type);
CREATE INDEX IF NOT EXISTS idx_alerts_created_at ON processor_alerts(created_at);
-- Add comments
COMMENT ON TABLE processor_alerts IS 'Processor state machine alerts for dependency/resource/output issues';
COMMENT ON COLUMN processor_alerts.alert_type IS 'Alert types: dependency_not_met, resource_exhausted, output_invalid, timeout';