Booking trace API

This commit is contained in:
mr 2024-08-21 15:32:10 +02:00
parent 4db037afd0
commit 9a6ab5c29c

View File

@ -1,6 +1,7 @@
package tools package tools
import ( import (
"encoding/json"
"errors" "errors"
"cloud.o-forge.io/core/oc-lib/dbs/mongo" "cloud.o-forge.io/core/oc-lib/dbs/mongo"
@ -50,10 +51,25 @@ func (a *API) CheckRemoteAPIs(urls []string) (State, int, error) {
// Check if the database is up // Check if the database is up
caller := NewHTTPCaller(map[string]map[METHOD]string{}) caller := NewHTTPCaller(map[string]map[METHOD]string{})
for _, url := range urls { for _, url := range urls {
_, err := caller.CallGet(url, "/version/status") var resp APIStatusResponse
b, err := caller.CallGet(url, "/version/status")
if err != nil { if err != nil {
return REDUCED_SERVICE, 200, err return REDUCED_SERVICE, 200, err
} }
json.Unmarshal(b, &resp)
if resp.Data.Code != 0 {
return REDUCED_SERVICE, 200, errors.New(url + " -> " + resp.Error)
}
} }
return ALIVE, 200, nil return ALIVE, 200, nil
} }
type APIStatusResponse struct {
Data *APIStatus `json:"data"`
Error string `json:"error"`
}
type APIStatus struct {
Code int `json:"code"`
State string `json:"state"`
}