raft.go
func (r *Raft) processHeartbeat(rpc RPC) {
	defer metrics.MeasureSince([]string{"raft", "rpc", "processHeartbeat"}, time.Now())

	// Check if we are shutdown, just ignore the RPC
	select {
	case <-r.shutdownCh:
		return
	default:
	}

	// Ensure we are only handling a heartbeat
	switch cmd := rpc.Command.(type) {
	case *AppendEntriesRequest:
		r.appendEntries(rpc, cmd)
	default:
		r.logger.Error(fmt.Sprintf("Expected heartbeat, got command: %#v", rpc.Command))
		rpc.Respond(nil, fmt.Errorf("unexpected command"))
	}
}
func (r *Raft) processHeartbeat(rpc RPC) {
	defer metrics.MeasureSince([]string{"raft", "rpc", "processHeartbeat"}, time.Now())

	// Check if we are shutdown, just ignore the RPC
	select {
	case <-r.shutdownCh:
		return
	default:
	}

	// Ensure we are only handling a heartbeat
	switch cmd := rpc.Command.(type) {
	case *AppendEntriesRequest:
		r.appendEntries(rpc, cmd)
	default:
		r.logger.Error(fmt.Sprintf("Expected heartbeat, got command: %#v", rpc.Command))
		rpc.Respond(nil, fmt.Errorf("unexpected command"))
	}
}
func ( r * Raft ) processHeartbeat ( rpc RPC ) { defer metrics . MeasureSince ( [ ] string { " " , " " , " " } , time . Now ( ) ) // Check if we are shutdown, just ignore the RPC select { case <- r . shutdownCh : return default : } // Ensure we are only handling a heartbeat switch cmd := rpc . Command . ( type ) { case * AppendEntriesRequest : r . appendEntries ( rpc , cmd ) default : r . logger . Error ( fmt . Sprintf ( " " , rpc . Command ) ) rpc . Respond ( nil , fmt . Errorf ( " " ) ) } }
// processHeartbeat is a special handler used just for heartbeat requests
// so that they can be fast-pathed if a transport supports it. This must only
// be called from the main thread.
processHeartbeat is a special handler used just for heartbeat requests so that they can be fast - pathed if a transport supports it . This must only be called from the main thread .