righvalor 0.1.0

RighValor: AI Infrastructure and Applications Framework for the Far Edge
use righ_dm_rs::RighNodeID;

/// Public alias for Valor's node identifier
pub type ValorID = RighNodeID;

/// Extension methods for naming conventions derived from a ValorID
pub trait ValorIdExt {
    /// new master id
    fn new_master(id: &str) -> Self;
    /// new worker id
    fn new_worker(id: &str) -> Self;
    /// Get the canonical worker actor name for this ID
    fn worker_actor_name(&self) -> String;
    /// Get the shared workers process-group name
    fn workers_pg_name() -> String;
    /// Get the masters process-group name
    fn masters_pg_name() -> String;
}

impl ValorIdExt for ValorID {
    fn new_master(id: &str) -> Self {
        RighNodeID::new(&format!("Master-{id}"))
    }

    fn new_worker(id: &str) -> Self {
        RighNodeID::new(&format!("Worker-{id}"))
    }

    fn worker_actor_name(&self) -> String {
        self.to_string()
    }

    fn workers_pg_name() -> String {
        "valor.workers".to_string()
    }

    fn masters_pg_name() -> String {
        "valor.master".to_string()
    }
}