tools
This commit is contained in:
parent
08e9ee67fe
commit
b49685aa82
14
tools/api.go
14
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
|
||||
|
@ -63,7 +63,7 @@ var Str = [...]string{
|
||||
"workspace",
|
||||
"resource_model",
|
||||
"peer",
|
||||
"shared_workspace",
|
||||
"collaborative_area",
|
||||
"rule",
|
||||
"booking",
|
||||
"workflow_history",
|
||||
|
Loading…
Reference in New Issue
Block a user