etcdserver/api/etcdhttp/metrics.go
func checkHealth(srv etcdserver.ServerV2) Health {
	h := Health{Health: "true"}

	as := srv.Alarms()
	if len(as) > 0 {
		h.Health = "false"
	}

	if h.Health == "true" {
		if uint64(srv.Leader()) == raft.None {
			h.Health = "false"
		}
	}

	if h.Health == "true" {
		ctx, cancel := context.WithTimeout(context.Background(), time.Second)
		_, err := srv.Do(ctx, etcdserverpb.Request{Method: "QGET"})
		cancel()
		if err != nil {
			h.Health = "false"
		}
	}

	if h.Health == "true" {
		healthSuccess.Inc()
	} else {
		healthFailed.Inc()
	}
	return h
}
func checkHealth(srv etcdserver.ServerV2) Health {
	h := Health{Health: "true"}

	as := srv.Alarms()
	if len(as) > 0 {
		h.Health = "false"
	}

	if h.Health == "true" {
		if uint64(srv.Leader()) == raft.None {
			h.Health = "false"
		}
	}

	if h.Health == "true" {
		ctx, cancel := context.WithTimeout(context.Background(), time.Second)
		_, err := srv.Do(ctx, etcdserverpb.Request{Method: "QGET"})
		cancel()
		if err != nil {
			h.Health = "false"
		}
	}

	if h.Health == "true" {
		healthSuccess.Inc()
	} else {
		healthFailed.Inc()
	}
	return h
}
func checkHealth ( srv etcdserver . ServerV2 ) Health { h := Health { Health : " " } as := srv . Alarms ( ) if len ( as ) > 0 { h . Health = " " } if h . Health == " " { if uint64 ( srv . Leader ( ) ) == raft . None { h . Health = " " } } if h . Health == " " { ctx , cancel := context . WithTimeout ( context . Background ( ) , time . Second ) _ , err := srv . Do ( ctx , etcdserverpb . Request { Method : " " } ) cancel ( ) if err != nil { h . Health = " " } } if h . Health == " " { healthSuccess . Inc ( ) } else { healthFailed . Inc ( ) } return h }
// TODO: server NOSPACE, etcdserver.ErrNoLeader in health API
TODO : server NOSPACE etcdserver . ErrNoLeader in health API