use crate::pod_coordination::types::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum ChangeType {
#[default]
Added,
Removed,
Modified,
}
#[derive(Debug, Clone)]
pub struct DependencyEdge {
pub from: u64,
pub to: u64,
pub source: u64,
pub target: u64,
pub edge_type: EdgeType,
pub weight: f64,
pub metadata: EdgeMetadata,
pub timestamp: std::time::Instant,
}
impl Default for DependencyEdge {
fn default() -> Self {
Self {
from: 0,
to: 0,
source: 0,
target: 0,
edge_type: EdgeType::default(),
weight: 0.0,
metadata: EdgeMetadata::default(),
timestamp: std::time::Instant::now(),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct DependencyGraph {
pub nodes: Vec<GraphNode>,
pub edges: Vec<DependencyEdge>,
}
impl DependencyGraph {
pub fn new() -> Self {
Self::default()
}
pub fn add_node(&mut self, node: GraphNode) {
self.nodes.push(node);
}
pub fn add_edge(&mut self, edge: DependencyEdge) {
self.edges.push(edge);
}
pub fn has_cycle(&self) -> bool {
false
}
}
#[derive(Debug, Clone, Default)]
pub struct EdgeMetadata {
pub weight: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum EdgeType {
#[default]
Dependency,
Resource,
Communication,
WaitsFor,
}
#[derive(Debug, Clone, Default)]
pub struct GraphChange {
pub change_type: ChangeType,
}
#[derive(Debug, Clone, Default)]
pub struct GraphHistory {
pub snapshots: Vec<GraphSnapshot>,
}
#[derive(Debug, Clone, Default)]
pub struct GraphMetadata {
pub properties: HashMap<String, String>,
}
#[derive(Debug, Clone)]
pub struct GraphNode {
pub id: u64,
pub node_type: NodeType,
pub state: NodeState,
pub metadata: GraphMetadata,
pub timestamp: std::time::Instant,
}
impl Default for GraphNode {
fn default() -> Self {
Self {
id: 0,
node_type: NodeType::default(),
state: NodeState::default(),
metadata: GraphMetadata::default(),
timestamp: std::time::Instant::now(),
}
}
}
#[derive(Debug, Clone, Default)]
pub struct GraphOptimizationState {
pub optimized: bool,
}
#[derive(Debug, Clone, Default)]
pub struct GraphProperties {
pub is_cyclic: bool,
}
#[derive(Debug, Clone, Default)]
pub struct GraphSnapshot {
pub timestamp_ms: u64,
pub graph: DependencyGraph,
}
#[derive(Debug, Clone, Default)]
pub struct GraphStatistics {
pub node_count: usize,
pub edge_count: usize,
}
#[derive(Debug, Clone, Default)]
pub struct NodeMetadata {
pub properties: HashMap<String, String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum NodeState {
#[default]
Active,
Waiting,
Blocked,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum NodeType {
#[default]
Process,
Resource,
Lock,
}
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum OptimizationOperation {
#[default]
Merge,
Split,
Remove,
}
#[derive(Debug, Clone, Default)]
pub struct OptimizationRecord {
pub operation: OptimizationOperation,
}
#[derive(Debug, Clone, Default)]
pub struct OptimizationStatistics {
pub operations_count: usize,
}
#[derive(Debug, Clone, Default)]
pub struct PerformanceImpact {
pub improvement_percent: f64,
}