// AddHealthResponseWithSecondsBehindMaster adds a faked health response to the
// buffer channel. Only "seconds_behind_master" is different in this message.
552346
func (q *StreamHealthQueryService) AddHealthResponseWithSecondsBehindMaster(replicationLag uint32) {
	q.healthResponses <- &querypb.StreamHealthResponse{
		Target:  proto.Clone(&q.target).(*querypb.Target),
		Serving: true,
		RealtimeStats: &querypb.RealtimeStats{
			SecondsBehindMaster: replicationLag,
		},
	}
}
1343865
func AddChecker(name string, check func() (interface{}, error)) {
	checker := healthChecker{name: name, check: check}
	checkers = append(checkers, checker)
}
434163
func NewHealthCheck() http.Handler {
	return api.HTTPHandler{
		Handler: api.HandlerFunc(healthHandler),
		Methods: []string{"GET"},
	}
}
565012
func (q *StreamHealthQueryService) StreamHealth(ctx context.Context, callback func(*querypb.StreamHealthResponse) error) error {
	for shr := range q.healthResponses {
		callback(shr)
	}
	return nil
}
1154256
func (l *State) AddCheck(check *structs.HealthCheck, token string) error {
	l.Lock()
	defer l.Unlock()

	return l.addCheckLocked(check, token)
}
1303964
func (c *Check) CheckHealth(ctx context.Context) Response {
	response := Response{
		Name:   "Health",
		Status: StatusPass,
		Checks: make(Responses, len(c.healthChecks)),
	}
	for i, ch := range c.healthChecks {
		resp := ch.Check(ctx)
		if resp.Status != StatusPass {
			response.Status = resp.Status
		}
		response.Checks[i] = resp
	}
	sort.Sort(response.Checks)
	return response
}
1014645
func (router *SimpleRouter) AddHealthCheckAt(path string, callback thealthcheck.CallbackFunc) {
	thealthcheck.AddEndpoint("/"+router.GetID()+path, callback)
}
132344
func (s *CreateEndpointGroupInput) SetHealthCheckIntervalSeconds(v int64) *CreateEndpointGroupInput {
	s.HealthCheckIntervalSeconds = &v
	return s
}
952403
func (o *GetHealthzOK) WithPayload(payload *models.StatusResponse) *GetHealthzOK {
	o.Payload = payload
	return o
}
1029584
func (r *Recorder) AddResponse(m ResponseErrorsArgs) error {
	return errors.Trace(r.log.AddResponse(ResponseErrors{
		ConversationID: r.callID,
		ConnectionID:   r.connectionID,
		RequestID:      m.RequestID,
		When:           r.clock.Now().Format(time.RFC3339),
		Errors:         m.Errors,
	}))
}
1085135
func (t *toolbox) AddHealthCheck(hc HealthChecker) {
	t.healthCheckJobs = append(t.healthCheckJobs, &healthCheck{
		HealthChecker: hc,
	})
}
1342995
func (s *GenericAPIServer) AddHealthzChecks(checks ...healthz.HealthzChecker) error {
	s.healthzLock.Lock()
	defer s.healthzLock.Unlock()

	if s.healthzCreated {
		return fmt.Errorf("unable to add because the healthz endpoint has already been created")
	}

	s.healthzChecks = append(s.healthzChecks, checks...)
	return nil
}
923424
func (h *HealthChecks) ServeHTTP(rw http.ResponseWriter, r *http.Request) {
	if !strings.HasPrefix(r.URL.Path, filepath.Join(h.basePath, "health")) && !strings.HasPrefix(r.URL.Path, filepath.Join(h.basePath, "audit", "health")) {
		h.next.ServeHTTP(rw, r)
		return
	}

	metrics.RunHealthchecks()
	var errors []string
	metrics.DefaultRegistry.Each(func(name string, metric interface{}) {
		if hc, ok := metric.(metrics.Healthcheck); ok {
			if hc.Error() != nil {
				errors = append(errors, name+": failed, because: "+hc.Error().Error()+"\n")
			}
		}
	})

	if len(errors) > 0 {
		rw.WriteHeader(http.StatusInternalServerError)
		for _, err := range errors {
			rw.Write([]byte(err))
		}
		return
	}

	rw.WriteHeader(http.StatusOK)
	rw.Write([]byte("OK"))
}
333259
func (m *Monitor) AddCheck(check *Check) {
	m.Lock()
	defer m.Unlock()
	log.Printf("Adding health check: %s (ID: %s), Args: %s", check.Type, check.ID, check.Args)
	m.Checks[check.ID] = check
}
1016058
func (s *TargetGroup) SetHealthCheckIntervalSeconds(v int64) *TargetGroup {
	s.HealthCheckIntervalSeconds = &v
	return s
}
115830
func SendResponseWithMessage(w http.ResponseWriter, result interface{}, message string, code int) error {
	response := NewSuccessResponseWithMessage(result, message, code)
	w.Header().Set("Content-Type", "application/json")
	enc := json.NewEncoder(w)
	err := enc.Encode(response)
	return err
}
446778
func (s *Server) newHealthChecker(ctx context.Context) http.Handler {
	h := &healthChecker{s: s}

	// Perform one health check synchronously so the returned handler returns
	// valid data immediately.
	h.runHealthCheck()

	go func() {
		for {
			select {
			case <-ctx.Done():
				return
			case <-time.After(time.Second * 15):
			}
			h.runHealthCheck()
		}
	}()
	return h
}