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) {
|
func (a *API) SubscribeRouter(infos []*beego.ControllerInfo) {
|
||||||
nats := NewNATSCaller()
|
nats := NewNATSCaller()
|
||||||
discovery := map[string]interface{}{}
|
discovery := map[string][]string{}
|
||||||
for _, info := range infos {
|
for _, info := range infos {
|
||||||
methods := []string{}
|
path := strings.ReplaceAll(info.GetPattern(), "/oc/", "/"+strings.ReplaceAll(config.GetAppName(), "oc-", ""))
|
||||||
for k, v := range info.GetMethod() {
|
for k, v := range info.GetMethod() {
|
||||||
|
if discovery[path] == nil {
|
||||||
|
discovery[path] = []string{}
|
||||||
|
}
|
||||||
if strings.Contains(strings.ToLower(v), "internal") {
|
if strings.Contains(strings.ToLower(v), "internal") {
|
||||||
methods = append(methods, "INTERNAL"+k)
|
discovery[path] = append(discovery[path], "INTERNAL"+k)
|
||||||
} else {
|
} 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)
|
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
|
for _, api := range apis { // Check the state of each remote API in the list
|
||||||
var resp APIStatusResponse
|
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)
|
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 {
|
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
|
||||||
|
@ -63,7 +63,7 @@ var Str = [...]string{
|
|||||||
"workspace",
|
"workspace",
|
||||||
"resource_model",
|
"resource_model",
|
||||||
"peer",
|
"peer",
|
||||||
"shared_workspace",
|
"collaborative_area",
|
||||||
"rule",
|
"rule",
|
||||||
"booking",
|
"booking",
|
||||||
"workflow_history",
|
"workflow_history",
|
||||||
|
Loading…
Reference in New Issue
Block a user