pub fn propose(
        &mut self,
        cb: Callback,
        req: RaftCmdRequest,
        mut err_resp: RaftCmdResponse,
        metrics: &mut RaftProposeMetrics,
    ) -> bool {
        if self.pending_remove {
            return false;
        }

        metrics.all += 1;

        let mut is_conf_change = false;

        let res = match self.get_handle_policy(&req) {
            Ok(RequestPolicy::ReadLocal) => {
                self.read_local(req, cb, metrics);
                return false;
            }
            Ok(RequestPolicy::ReadIndex) => return self.read_index(req, err_resp, cb, metrics),
            Ok(RequestPolicy::ProposeNormal) => self.propose_normal(req, metrics),
            Ok(RequestPolicy::ProposeTransferLeader) => {
                return self.propose_transfer_leader(req, cb, metrics)
            }
            Ok(RequestPolicy::ProposeConfChange) => {
                is_conf_change = true;
                self.propose_conf_change(&req, metrics)
            }
            Err(e) => Err(e),
        };

        match res {
            Err(e) => {
                cmd_resp::bind_error(&mut err_resp, e);
                cb.invoke_with_response(err_resp);
                false
            }
            Ok(idx) => {
                let meta = ProposalMeta {
                    index: idx,
                    term: self.term(),
                    renew_lease_time: None,
                };
                self.post_propose(meta, is_conf_change, cb);
                true
            }
        }
    }
/// Propose a request.
///
/// Return true means the request has been proposed successfully.
Propose a request.
Return true means the request has been proposed successfully.
Propose a request . Return true means the request has been proposed successfully .
pub fn propose(
        &mut self,
        cb: Callback,
        req: RaftCmdRequest,
        mut err_resp: RaftCmdResponse,
        metrics: &mut RaftProposeMetrics,
    ) -> bool {
        if self.pending_remove {
            return false;
        }
        metrics.all += 1;
        let mut is_conf_change = false;
        let res = match self.get_handle_policy(&req) {
            Ok(RequestPolicy::ReadLocal) => {
                self.read_local(req, cb, metrics);
                return false;
            }
            Ok(RequestPolicy::ReadIndex) => return self.read_index(req, err_resp, cb, metrics),
            Ok(RequestPolicy::ProposeNormal) => self.propose_normal(req, metrics),
            Ok(RequestPolicy::ProposeTransferLeader) => {
                return self.propose_transfer_leader(req, cb, metrics)
            }
            Ok(RequestPolicy::ProposeConfChange) => {
                is_conf_change = true;
                self.propose_conf_change(&req, metrics)
            }
            Err(e) => Err(e),
        };
        match res {
            Err(e) => {
                cmd_resp::bind_error(&mut err_resp, e);
                cb.invoke_with_response(err_resp);
                false
            }
            Ok(idx) => {
                let meta = ProposalMeta {
                    index: idx,
                    term: self.term(),
                    renew_lease_time: None,
                };
                self.post_propose(meta, is_conf_change, cb);
                true
            }
        }
    }
pub fn propose ( & mut self , cb : Callback , req : RaftCmdRequest , mut err_resp : RaftCmdResponse , metrics : & mut RaftProposeMetrics , ) -> bool { if self . pending_remove { return false ; } metrics . all += 1 ; let mut is_conf_change = false ; let res = match self . get_handle_policy ( & req ) { Ok ( RequestPolicy :: ReadLocal ) => { self . read_local ( req , cb , metrics ) ; return false ; } Ok ( RequestPolicy :: ReadIndex ) => return self . read_index ( req , err_resp , cb , metrics ) , Ok ( RequestPolicy :: ProposeNormal ) => self . propose_normal ( req , metrics ) , Ok ( RequestPolicy :: ProposeTransferLeader ) => { return self . propose_transfer_leader ( req , cb , metrics ) } Ok ( RequestPolicy :: ProposeConfChange ) => { is_conf_change = true ; self . propose_conf_change ( & req , metrics ) } Err ( e ) => Err ( e ) , } ; match res { Err ( e ) => { cmd_resp :: bind_error ( & mut err_resp , e ) ; cb . invoke_with_response ( err_resp ) ; false } Ok ( idx ) => { let meta = ProposalMeta { index : idx , term : self . term ( ) , renew_lease_time : None , } ; self . post_propose ( meta , is_conf_change , cb ) ; true } } }
Propose a request.
Propose a request .
&mut self
cb
Callback
req
RaftCmdRequest
err_resp
RaftCmdResponse
metrics
&mut RaftProposeMetrics