From b49685aa8223327d42ebf25f21f77d0f461bbb36 Mon Sep 17 00:00:00 2001 From: mr Date: Wed, 20 Nov 2024 10:39:20 +0100 Subject: [PATCH] tools --- tools/api.go | 14 +++++++------- tools/enums.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tools/api.go b/tools/api.go index 293494d..9d5be05 100644 --- a/tools/api.go +++ b/tools/api.go @@ -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{} + path := strings.ReplaceAll(info.GetPattern(), "/oc/", "/"+strings.ReplaceAll(config.GetAppName(), "oc-", "")) for k, v := range info.GetMethod() { + if discovery[path] == nil { + discovery[path] = []string{} + } if strings.Contains(strings.ToLower(v), "internal") { - methods = append(methods, "INTERNAL"+k) + discovery[path] = append(discovery[path], "INTERNAL"+k) } else { - methods = append(methods, k) + discovery[path] = append(discovery[path], k) } } - path := strings.ReplaceAll(info.GetPattern(), "/oc/", "/"+strings.ReplaceAll(config.GetAppName(), "oc-", "")) - discovery[path] = methods } 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 diff --git a/tools/enums.go b/tools/enums.go index 7e7857a..c1395b8 100644 --- a/tools/enums.go +++ b/tools/enums.go @@ -63,7 +63,7 @@ var Str = [...]string{ "workspace", "resource_model", "peer", - "shared_workspace", + "collaborative_area", "rule", "booking", "workflow_history",