pub async fn join(&self, req: JoinRequest) -> StoreResult<()> {
        // TODO: check if this node is already in learner list.
        let node = Some(Node {
            addr: req.addr,
            ..Default::default()
        });
        self.app_node
            .raft
            .add_learner(req.node_id, node, true)
            .await
            .map_err(|e| APIError::AddLearner(format!("{}", e)))?;

        if !req.voter {
            return Ok(());
        }
        let metrics = self.app_node.raft.metrics().borrow().clone();
        let membership = metrics.membership_config.get_configs();

        // TODO(xp): deal with joint config
        assert!(membership.get(1).is_none());

        // safe unwrap: if the first config is None, panic is the expected behavior
        // here.
        let mut membership = membership.get(0).unwrap().clone();

        if membership.contains(&req.node_id) {
            return Ok(());
        }
        membership.insert(req.node_id);

        self.change_membership(membership).await
    }
// join the node with the given ID, reachable at addr, to this node.
join the node with the given ID, reachable at addr, to this node.
join the node with the given ID reachable at addr to this node .
pub async fn join(&self, req: JoinRequest) -> StoreResult<()> {
        // TODO: check if this node is already in learner list.
        let node = Some(Node {
            addr: req.addr,
            ..Default::default()
        });
        self.app_node
            .raft
            .add_learner(req.node_id, node, true)
            .await
            .map_err(|e| APIError::AddLearner(format!("{}", e)))?;
        if !req.voter {
            return Ok(());
        }
        let metrics = self.app_node.raft.metrics().borrow().clone();
        let membership = metrics.membership_config.get_configs();
        // TODO(xp): deal with joint config
        assert!(membership.get(1).is_none());
        // safe unwrap: if the first config is None, panic is the expected behavior
        // here.
        let mut membership = membership.get(0).unwrap().clone();
        if membership.contains(&req.node_id) {
            return Ok(());
        }
        membership.insert(req.node_id);
        self.change_membership(membership).await
    }
pub async fn join ( & self , req : JoinRequest ) -> StoreResult < ( ) > { // TODO: check if this node is already in learner list. let node = Some ( Node { addr : req . addr , .. Default :: default ( ) } ) ; self . app_node . raft . add_learner ( req . node_id , node , true ) . await . map_err ( | e | APIError :: AddLearner ( format ! ( " " e ) ) ) ? ; if ! req . voter { return Ok ( ( ) ) ; } let metrics = self . app_node . raft . metrics ( ) . borrow ( ) . clone ( ) ; let membership = metrics . membership_config . get_configs ( ) ; // TODO(xp): deal with joint config assert ! ( membership get ( 1 ) is_none ( ) ) ; // safe unwrap: if the first config is None, panic is the expected behavior // here. let mut membership = membership . get ( 0 ) . unwrap ( ) . clone ( ) ; if membership . contains ( & req . node_id ) { return Ok ( ( ) ) ; } membership . insert ( req . node_id ) ; self . change_membership ( membership ) . await }
join the node with the given ID, reachable at addr, to this node.
join the node with the given ID reachable at addr to this node .
&self
req
JoinRequest
&self
req
JoinRequest