Simplify boilerplate for learning: stub inference and Postgres write
Removed ort/ndarray/image (ONNX Runtime inference) and sqlx (Postgres audit write). inference::detect() and the Postgres half of reporter::report() are now stubs with a comment for what real code goes there. Redis Streams XREADGROUP loop and the Redis pub/sub alert stay real. Verified with a clean cargo check --all-targets (0 warnings).
This commit is contained in:
@@ -6,13 +6,6 @@ pub struct Config {
|
||||
pub frame_stream: String,
|
||||
pub consumer_group: String,
|
||||
pub consumer_name: String,
|
||||
pub stream_block_ms: usize,
|
||||
pub stream_batch_size: usize,
|
||||
pub database_url: String,
|
||||
pub model_path: String,
|
||||
pub model_input_size: u32,
|
||||
pub confidence_threshold: f32,
|
||||
pub intra_op_threads: usize,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
@@ -22,21 +15,10 @@ impl Config {
|
||||
frame_stream: env_or("CONTINUUM_FRAME_STREAM", "stream:camera_frames"),
|
||||
consumer_group: env_or("CONTINUUM_CONSUMER_GROUP", "ai-worker"),
|
||||
consumer_name: env_or("CONTINUUM_CONSUMER_NAME", "ai-worker-1"),
|
||||
stream_block_ms: env_or("CONTINUUM_STREAM_BLOCK_MS", "5000").parse()?,
|
||||
stream_batch_size: env_or("CONTINUUM_STREAM_BATCH_SIZE", "16").parse()?,
|
||||
database_url: require("DATABASE_URL")?,
|
||||
model_path: env_or("CONTINUUM_MODEL_PATH", "./models/failure-detector.onnx"),
|
||||
model_input_size: env_or("CONTINUUM_MODEL_INPUT_SIZE", "640").parse()?,
|
||||
confidence_threshold: env_or("CONTINUUM_CONFIDENCE_THRESHOLD", "0.75").parse()?,
|
||||
intra_op_threads: env_or("CONTINUUM_INTRA_OP_THREADS", "4").parse()?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
fn require(key: &str) -> anyhow::Result<String> {
|
||||
env::var(key).map_err(|_| anyhow::anyhow!("missing required env var {key}"))
|
||||
}
|
||||
|
||||
fn env_or(key: &str, default: &str) -> String {
|
||||
env::var(key).unwrap_or_else(|_| default.to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user