/// Handle a heartbeat for the given client.
///
/// # Returns
///
/// This method returns the response to send back to the client.
Handle a heartbeat for the given client.
Handle a heartbeat for the given client .
pub fn heartbeat(&mut self, id: ClientId, client_state: ClientState) -> HeartBeatResponse {
        info!("heartbeat: {}({})", id, client_state);
        if self.is_training_complete {
            self.emit_event(Event::ResetHeartBeat(id));
            return HeartBeatResponse::Finish;
        }
        match client_state {
            // Reject any client we don't know about. They must first
            // send a rendez-vous request to be recognized by the
            // coordinator.
            ClientState::Unknown => HeartBeatResponse::Reject,
            // The client may have come back to life. But once a
            // client has become inactive, it has to send a new
            // rendez-vous request and be accepted by the coordinator,
            // so we reject this heartbeat.
            ClientState::DoneAndInactive => HeartBeatResponse::Reject,
            // Client that are waiting or done should stand by
            ClientState::Ignored | ClientState::Waiting | ClientState::Done => {
                self.emit_event(Event::ResetHeartBeat(id));
                HeartBeatResponse::StandBy
            }
            // If the client has been selected, notify them.
            ClientState::Selected => {
                self.emit_event(Event::ResetHeartBeat(id));
                HeartBeatResponse::Round(self.current_round)
            }
        }
    }
pub fn heartbeat ( & mut self , id : ClientId , client_state : ClientState ) -> HeartBeatResponse { info ! ( " " id client_state ) ; if self . is_training_complete { self . emit_event ( Event :: ResetHeartBeat ( id ) ) ; return HeartBeatResponse :: Finish ; } match client_state { // Reject any client we don't know about. They must first // send a rendez-vous request to be recognized by the // coordinator. ClientState :: Unknown => HeartBeatResponse :: Reject , // The client may have come back to life. But once a // client has become inactive, it has to send a new // rendez-vous request and be accepted by the coordinator, // so we reject this heartbeat. ClientState :: DoneAndInactive => HeartBeatResponse :: Reject , // Client that are waiting or done should stand by ClientState :: Ignored | ClientState :: Waiting | ClientState :: Done => { self . emit_event ( Event :: ResetHeartBeat ( id ) ) ; HeartBeatResponse :: StandBy } // If the client has been selected, notify them. ClientState :: Selected => { self . emit_event ( Event :: ResetHeartBeat ( id ) ) ; HeartBeatResponse :: Round ( self . current_round ) } } }
Handle a heartbeat for the given client.
Handle a heartbeat for the given client .
This method returns the response to send back to the client.
This method returns the response to send back to the client .
&mut self
id
ClientId
client_state
ClientState