include oc in racine path for remote calling
This commit is contained in:
parent
69fe3f8d76
commit
62705cc9b9
@ -43,9 +43,9 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string {
|
||||
r := regexp.MustCompile("(" + localhost + ":[0-9]+)")
|
||||
t := r.FindString(url)
|
||||
if t != "" {
|
||||
url = strings.Replace(url, t, dt.API()+":8080", -1)
|
||||
url = strings.Replace(url, t, dt.API()+":8080/oc", -1)
|
||||
} else {
|
||||
url = strings.ReplaceAll(url, localhost, dt.API()+":8080")
|
||||
url = strings.ReplaceAll(url, localhost, dt.API()+":8080/oc")
|
||||
}
|
||||
} else {
|
||||
url = url + "/" + dt.API()
|
||||
|
@ -91,7 +91,7 @@ func (a *API) CheckRemotePeer(url string) (State, map[string]int) {
|
||||
}
|
||||
|
||||
// CheckRemoteAPIs checks the state of remote APIs from your proper OC
|
||||
func (a *API) CheckRemoteAPIs(urls map[string]string) (State, map[string]string, error) {
|
||||
func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error) {
|
||||
// Check if the database is up
|
||||
new := map[string]string{}
|
||||
caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller
|
||||
@ -99,9 +99,9 @@ func (a *API) CheckRemoteAPIs(urls map[string]string) (State, map[string]string,
|
||||
e := ""
|
||||
state := ALIVE
|
||||
reachable := false
|
||||
for appName, url := range urls { // Check the state of each remote API in the list
|
||||
for _, api := range apis { // Check the state of each remote API in the list
|
||||
var resp APIStatusResponse
|
||||
b, err := caller.CallGet(url, "/version/status") // Call the status endpoint of the remote API (standard OC status endpoint)
|
||||
b, err := caller.CallGet(api.API()+":8080", "/oc/version/status") // Call the status endpoint of the remote API (standard OC status endpoint)
|
||||
if err != nil {
|
||||
state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service
|
||||
continue
|
||||
@ -111,7 +111,7 @@ func (a *API) CheckRemoteAPIs(urls map[string]string) (State, map[string]string,
|
||||
state = REDUCED_SERVICE // If the response is empty, return reduced service
|
||||
continue
|
||||
}
|
||||
new[appName] = resp.Data.State
|
||||
new[api.String()] = resp.Data.State
|
||||
if resp.Data.Code > code {
|
||||
code = resp.Data.Code
|
||||
e += resp.Error
|
||||
|
Loading…
Reference in New Issue
Block a user