use anyhow::Result;
use std::collections::HashMap;
use std::sync::Arc;
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct ExecutionId(pub String);
#[async_trait::async_trait]
pub trait CredentialResolver: Send + Sync {
async fn resolve(&self, alias: &str) -> Result<serde_json::Value>;
}
#[derive(Clone)]
pub struct ExecutionContext {
pub execution_id: ExecutionId,
pub credentials: Arc<dyn CredentialResolver>,
pub step_results: Arc<tokio::sync::RwLock<HashMap<String, serde_json::Value>>>,
pub workload: Arc<serde_json::Value>,
}
impl ExecutionContext {
pub fn new(
execution_id: ExecutionId,
credentials: Arc<dyn CredentialResolver>,
workload: serde_json::Value,
) -> Self {
Self {
execution_id,
credentials,
step_results: Arc::new(tokio::sync::RwLock::new(HashMap::new())),
workload: Arc::new(workload),
}
}
}