58 lines
1.9 KiB
Rust
58 lines
1.9 KiB
Rust
// API state - Shared application state for Axum handlers
|
|
|
|
use std::sync::Arc;
|
|
|
|
use vapora_rlm::storage::SurrealDBStorage;
|
|
use vapora_rlm::RLMEngine;
|
|
use vapora_workflow_engine::WorkflowOrchestrator;
|
|
|
|
use crate::services::{
|
|
AgentService, ProjectService, ProposalService, ProviderAnalyticsService, TaskService,
|
|
};
|
|
|
|
/// Application state shared across all API handlers
|
|
#[derive(Clone)]
|
|
pub struct AppState {
|
|
pub project_service: Arc<ProjectService>,
|
|
pub task_service: Arc<TaskService>,
|
|
pub agent_service: Arc<AgentService>,
|
|
pub proposal_service: Arc<ProposalService>,
|
|
pub provider_analytics_service: Arc<ProviderAnalyticsService>,
|
|
pub workflow_orchestrator: Option<Arc<WorkflowOrchestrator>>,
|
|
pub rlm_engine: Option<Arc<RLMEngine<SurrealDBStorage>>>,
|
|
}
|
|
|
|
impl AppState {
|
|
/// Create a new AppState instance
|
|
pub fn new(
|
|
project_service: ProjectService,
|
|
task_service: TaskService,
|
|
agent_service: AgentService,
|
|
proposal_service: ProposalService,
|
|
provider_analytics_service: ProviderAnalyticsService,
|
|
) -> Self {
|
|
Self {
|
|
project_service: Arc::new(project_service),
|
|
task_service: Arc::new(task_service),
|
|
agent_service: Arc::new(agent_service),
|
|
proposal_service: Arc::new(proposal_service),
|
|
provider_analytics_service: Arc::new(provider_analytics_service),
|
|
workflow_orchestrator: None,
|
|
rlm_engine: None,
|
|
}
|
|
}
|
|
|
|
/// Add workflow orchestrator to state
|
|
#[allow(dead_code)]
|
|
pub fn with_workflow_orchestrator(mut self, orchestrator: Arc<WorkflowOrchestrator>) -> Self {
|
|
self.workflow_orchestrator = Some(orchestrator);
|
|
self
|
|
}
|
|
|
|
/// Add RLM engine to state
|
|
pub fn with_rlm_engine(mut self, rlm_engine: Arc<RLMEngine<SurrealDBStorage>>) -> Self {
|
|
self.rlm_engine = Some(rlm_engine);
|
|
self
|
|
}
|
|
}
|