//! Node management for distributed storage
//!
//! This module provides abstractions for managing storage nodes,
//! including node discovery, health checking, and communication.

pub mod client;
pub mod mock;
pub mod registry;

pub use client::{NodeClient, NodeClientTrait};
pub use mock::{MockNodeClient, MockNodeRegistry};
pub use registry::{NodeInfo, NodeRegistry, StaticNodeRegistry};

use thiserror::Error;

/// Errors that can occur during node operations
#[derive(Debug, Error)]
pub enum NodeError {
    #[error("Connection failed to node {node_id}: {reason}")]
    ConnectionFailed { node_id: String, reason: String },

    #[error("RPC failed: {0}")]
    RpcFailed(String),

    #[error("Node not found: {0}")]
    NotFound(String),

    #[error("Timeout waiting for response")]
    Timeout,

    #[error("Node unhealthy: {0}")]
    Unhealthy(String),

    #[error("Not enough healthy nodes: need {needed}, have {available}")]
    NotEnoughNodes { needed: usize, available: usize },
}

/// Result type for node operations
pub type NodeResult<T> = Result<T, NodeError>;
