This commit is contained in:
mr 2024-11-20 10:39:20 +01:00
parent 08e9ee67fe
commit b49685aa82
2 changed files with 8 additions and 8 deletions

View File

@ -89,18 +89,19 @@ func (a *API) ListenRouter(exec func(msg map[string]interface{})) {
func (a *API) SubscribeRouter(infos []*beego.ControllerInfo) {
nats := NewNATSCaller()
discovery := map[string]interface{}{}
discovery := map[string][]string{}
for _, info := range infos {
methods := []string{}
for k, v := range info.GetMethod() {
if strings.Contains(strings.ToLower(v), "internal") {
methods = append(methods, "INTERNAL"+k)
} else {
methods = append(methods, k)
}
}
path := strings.ReplaceAll(info.GetPattern(), "/oc/", "/"+strings.ReplaceAll(config.GetAppName(), "oc-", ""))
discovery[path] = methods
for k, v := range info.GetMethod() {
if discovery[path] == nil {
discovery[path] = []string{}
}
if strings.Contains(strings.ToLower(v), "internal") {
discovery[path] = append(discovery[path], "INTERNAL"+k)
} else {
discovery[path] = append(discovery[path], k)
}
}
}
nats.SetNATSPub("api", DISCOVERY, discovery)
}
@ -137,7 +138,6 @@ func (a *API) CheckRemoteAPIs(apis []DataType) (State, map[string]string, error)
for _, api := range apis { // Check the state of each remote API in the list
var resp APIStatusResponse
b, err := caller.CallGet("http://"+api.API()+":8080", "/oc/version/status") // Call the status endpoint of the remote API (standard OC status endpoint)
fmt.Println(err)
if err != nil {
state = REDUCED_SERVICE // If a remote API is not reachable, return reduced service
continue

View File

@ -63,7 +63,7 @@ var Str = [...]string{
"workspace",
"resource_model",
"peer",
"shared_workspace",
"collaborative_area",
"rule",
"booking",
"workflow_history",