feat: add ExecutionMode and CliExecutor for CLI orchestration
新增功能: - ExecutionMode 枚舉 (Python/Cli/Hybrid) - EXECUTION_MODE 全局配置 - CliExecutor 結構體 實現細節: - config.rs: 添加 ExecutionMode 和相關函數 - executor.rs: 添加 CliExecutor 用於調用 Swift/Rust CLI 配置方式: - MOMENTRY_EXECUTION_MODE=python/cli/hybrid (默認: hybrid) 下一步: - 實現具體的 CLI 調用邏輯 - 添加環境變數切換測試
This commit is contained in:
@@ -2,6 +2,33 @@ use once_cell::sync::Lazy;
|
||||
use std::env;
|
||||
use std::sync::RwLock;
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Execution mode for processors (Python, CLI, or Hybrid)
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum ExecutionMode {
|
||||
Python, // Use Python scripts (default)
|
||||
Cli, // Use Swift/Rust CLI tools
|
||||
Hybrid, // Use CLI for performance-critical processors, Python for others
|
||||
}
|
||||
|
||||
pub static EXECUTION_MODE: Lazy<ExecutionMode> = Lazy::new(|| {
|
||||
match env::var("MOMENTRY_EXECUTION_MODE")
|
||||
.unwrap_or_else(|_| "hybrid".to_string())
|
||||
.to_lowercase()
|
||||
.as_str()
|
||||
{
|
||||
"cli" => ExecutionMode::Cli,
|
||||
"python" => ExecutionMode::Python,
|
||||
_ => ExecutionMode::Hybrid,
|
||||
}
|
||||
});
|
||||
|
||||
pub fn get_execution_mode() -> ExecutionMode {
|
||||
*EXECUTION_MODE
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Runtime switches (mutable via API, persisted in memory)
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user