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

Method Health

edgraph/server.go:1226–1266  ·  view source on GitHub ↗

Health handles /health and /health?all requests.

(ctx context.Context, all bool)

Source from the content-addressed store, hash-verified

1224
1225// Health handles /health and /health?all requests.
1226func (s *Server) Health(ctx context.Context, all bool) (*api.Response, error) {
1227 if ctx.Err() != nil {
1228 return nil, ctx.Err()
1229 }
1230
1231 var healthAll []pb.HealthInfo
1232 if all {
1233 if err := AuthorizeGuardians(ctx); err != nil {
1234 return nil, err
1235 }
1236 pool := conn.GetPools().GetAll()
1237 for _, p := range pool {
1238 if p.Addr == x.WorkerConfig.MyAddr {
1239 continue
1240 }
1241 healthAll = append(healthAll, p.HealthInfo())
1242 }
1243 }
1244
1245 // Append self.
1246 healthAll = append(healthAll, pb.HealthInfo{
1247 Instance: "alpha",
1248 Address: x.WorkerConfig.MyAddr,
1249 Status: "healthy",
1250 Group: strconv.Itoa(int(worker.GroupId())),
1251 Version: x.Version(),
1252 Uptime: int64(time.Since(x.WorkerConfig.StartTime) / time.Second),
1253 LastEcho: time.Now().Unix(),
1254 Ongoing: worker.GetOngoingTasks(),
1255 Indexing: schema.GetIndexingPredicates(),
1256 EeFeatures: worker.GetFeaturesList(),
1257 MaxAssigned: posting.Oracle().MaxAssigned(),
1258 })
1259
1260 var err error
1261 var jsonOut []byte
1262 if jsonOut, err = json.Marshal(healthAll); err != nil {
1263 return nil, errors.Errorf("Unable to Marshal. Err %v", err)
1264 }
1265 return &api.Response{Json: jsonOut}, nil
1266}
1267
1268// Filter out the tablets that do not belong to the requestor's namespace.
1269func filterTablets(ctx context.Context, ms *pb.MembershipState) error {

Callers 2

healthCheckFunction · 0.80
resolveHealthFunction · 0.80

Calls 12

GetPoolsFunction · 0.92
GroupIdFunction · 0.92
VersionFunction · 0.92
GetOngoingTasksFunction · 0.92
GetIndexingPredicatesFunction · 0.92
GetFeaturesListFunction · 0.92
OracleFunction · 0.92
AuthorizeGuardiansFunction · 0.85
GetAllMethod · 0.80
HealthInfoMethod · 0.80
MaxAssignedMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected