use async_trait::async_trait;
use chrono::{DateTime, Utc};
use crate::compare::Comparison;
use crate::earned_value::{
BaselineOutcome, BaselineRequest, BaselineTaken, EvReport, SnapshotOutcome, SnapshotRequest,
};
use crate::plan::{
AcceptRequest, AcquireRequest, Cohort, ComparePlansRequest, ForceReleaseRequest, ForkRequest,
HeartbeatRequest, MarkStatusRequest, PlanDefinition, PlanGraph, PlanId, PlanLineSummary,
PlanStatus, PlannerError, ReviseRequest, SelectOutcome, SyncOutcome, SyncRequest,
};
use crate::project::ProjectRoot;
use crate::revise::RevisionDiff;
#[async_trait]
pub trait Planner: Send + Sync {
async fn submit_plan(&self, graph: PlanGraph) -> Result<PlanId, PlannerError>;
async fn acquire_cohort(&self, req: AcquireRequest) -> Result<Cohort, PlannerError>;
async fn mark_status(
&self,
req: MarkStatusRequest,
) -> Result<Option<BaselineTaken>, PlannerError>;
async fn heartbeat(&self, req: HeartbeatRequest) -> Result<(), PlannerError>;
async fn status(&self, plan_id: &PlanId) -> Result<PlanStatus, PlannerError>;
async fn get_plan(&self, plan_id: &PlanId) -> Result<PlanDefinition, PlannerError>;
async fn force_release(&self, req: ForceReleaseRequest) -> Result<(), PlannerError>;
async fn accept(&self, req: AcceptRequest) -> Result<(), PlannerError>;
async fn sync_plan(&self, req: SyncRequest) -> Result<SyncOutcome, PlannerError>;
async fn list_plans(
&self,
project: &str,
include_archived: bool,
) -> Result<Vec<PlanLineSummary>, PlannerError>;
async fn revision_graph(
&self,
plan_id: &PlanId,
revision: Option<u32>,
) -> Result<(u32, PlanGraph), PlannerError>;
async fn revise_plan(&self, req: ReviseRequest) -> Result<(u32, RevisionDiff), PlannerError>;
async fn select_variant(
&self,
plan_id: &PlanId,
force: bool,
) -> Result<SelectOutcome, PlannerError>;
async fn archive(
&self,
project: &str,
name: &str,
variant: Option<&str>,
archived: bool,
force: bool,
) -> Result<(), PlannerError>;
async fn fork_plan(&self, req: ForkRequest) -> Result<SyncOutcome, PlannerError>;
async fn compare_plans(&self, req: ComparePlansRequest) -> Result<Comparison, PlannerError>;
async fn export_plan(
&self,
plan_id: &PlanId,
root: &ProjectRoot,
path: Option<&str>,
force: bool,
) -> Result<String, PlannerError>;
async fn baseline(&self, req: BaselineRequest) -> Result<BaselineOutcome, PlannerError>;
async fn ev(
&self,
plan_id: &PlanId,
as_of: Option<DateTime<Utc>>,
) -> Result<EvReport, PlannerError>;
async fn snapshot(&self, req: SnapshotRequest) -> Result<SnapshotOutcome, PlannerError>;
}