Health handles /health and /health?all requests.
(ctx context.Context, all bool)
| 1224 | |
| 1225 | // Health handles /health and /health?all requests. |
| 1226 | func (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. |
| 1269 | func filterTablets(ctx context.Context, ms *pb.MembershipState) error { |
no test coverage detected