mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-04-22 09:56:38 +00:00
Implement a stub of the new endpoint
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
This commit is contained in:
@@ -54,6 +54,13 @@ func CheckNeighboursNeighbours(ctx context.Context) *models.CheckAllResults {
|
||||
return CheckAllPods(ctx, SelectPods())
|
||||
}
|
||||
|
||||
// CheckCluster does a CheckNeighboursNeighbours and analyses results to produce a binary OK or not OK
|
||||
func CheckCluster(ctx context.Context) (bool, *models.ClusterHealthResults) {
|
||||
|
||||
response := models.ClusterHealthResults{}
|
||||
return true, &response
|
||||
}
|
||||
|
||||
type PingAllPodsResult struct {
|
||||
podName string
|
||||
podResult models.PodResult
|
||||
|
||||
@@ -94,6 +94,24 @@ func configureAPI(api *operations.GoldpingerAPI) http.Handler {
|
||||
return operations.NewCheckAllPodsOK().WithPayload(goldpinger.CheckNeighboursNeighbours(ctx))
|
||||
})
|
||||
|
||||
api.ClusterHealthHandler = operations.ClusterHealthHandlerFunc(
|
||||
func(params operations.ClusterHealthParams) middleware.Responder {
|
||||
goldpinger.CountCall("received", "cluster_health")
|
||||
|
||||
ctx, cancel := context.WithTimeout(
|
||||
params.HTTPRequest.Context(),
|
||||
time.Duration(goldpinger.GoldpingerConfig.CheckAllTimeoutMs)*time.Millisecond,
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
ok, payload := goldpinger.CheckCluster(ctx)
|
||||
if ok {
|
||||
return operations.NewClusterHealthOK().WithPayload(payload)
|
||||
} else {
|
||||
return operations.NewClusterHealthServiceUnavailable().WithPayload(payload)
|
||||
}
|
||||
})
|
||||
|
||||
api.HealthzHandler = operations.HealthzHandlerFunc(
|
||||
func(params operations.HealthzParams) middleware.Responder {
|
||||
goldpinger.CountCall("received", "healthz")
|
||||
|
||||
Reference in New Issue
Block a user