MCPcopy
hub / github.com/dgraph-io/dgraph / zeroHealth

Method zeroHealth

dgraph/cmd/zero/http.go:237–254  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

235}
236
237func (s *Server) zeroHealth(ctx context.Context) (*api.Response, error) {
238 if ctx.Err() != nil {
239 return nil, errors.Wrap(ctx.Err(), "http request context error")
240 }
241 health := &pb.HealthInfo{
242 Instance: "zero",
243 Address: x.WorkerConfig.MyAddr,
244 Status: "healthy",
245 Version: x.Version(),
246 Uptime: int64(time.Since(x.WorkerConfig.StartTime) / time.Second),
247 LastEcho: time.Now().Unix(),
248 }
249 jsonOut, err := json.Marshal(health)
250 if err != nil {
251 return nil, errors.Wrapf(err, "unable to marshal zero health, error")
252 }
253 return &api.Response{Json: jsonOut}, nil
254}
255
256func (st *state) pingResponse(w http.ResponseWriter, r *http.Request) {
257 x.AddCorsHeaders(w)

Callers 1

pingResponseMethod · 0.80

Calls 1

VersionFunction · 0.92

Tested by

no test coverage detected