include oc in racine path for remote calling

This commit is contained in:
mr 2024-10-15 10:23:07 +02:00
parent 69fe3f8d76
commit 62705cc9b9
2 changed files with 6 additions and 6 deletions

View File

@ -43,9 +43,9 @@ func (p *PeerCache) urlFormat(url string, dt tools.DataType) string {
r := regexp.MustCompile("(" + localhost + ":[0-9]+)") r := regexp.MustCompile("(" + localhost + ":[0-9]+)")
t := r.FindString(url) t := r.FindString(url)
if t != "" { if t != "" {
url = strings.Replace(url, t, dt.API()+":8080", -1) url = strings.Replace(url, t, dt.API()+":8080/oc", -1)
} else { } else {
url = strings.ReplaceAll(url, localhost, dt.API()+":8080") url = strings.ReplaceAll(url, localhost, dt.API()+":8080/oc")
} }
} else { } else {
url = url + "/" + dt.API() url = url + "/" + dt.API()

View File

@ -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 // 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 // Check if the database is up
new := map[string]string{} new := map[string]string{}
caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller 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 := "" e := ""
state := ALIVE state := ALIVE
reachable := false 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 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 { if err != nil {
state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service
continue 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 state = REDUCED_SERVICE // If the response is empty, return reduced service
continue continue
} }
new[appName] = resp.Data.State new[api.String()] = resp.Data.State
if resp.Data.Code > code { if resp.Data.Code > code {
code = resp.Data.Code code = resp.Data.Code
e += resp.Error e += resp.Error