wait for NATS

This commit is contained in:
mr
2025-06-24 08:49:53 +02:00
parent e84d262f38
commit 2c8dcbe93d
2 changed files with 38 additions and 29 deletions

View File

@@ -110,14 +110,14 @@ func (a *API) SubscribeRouter(infos []*beego.ControllerInfo) {
}
}
}
nats.SetNATSPub("api", DISCOVERY, discovery)
go nats.SetNATSPub("api", DISCOVERY, discovery)
}
// CheckRemotePeer checks the state of a remote peer
func (a *API) CheckRemotePeer(url string) (State, map[string]int) {
// Check if the database is up
var resp APIStatusResponse
caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller
caller := NewHTTPCaller(map[DataType]map[METHOD]string{}) // Create a new http caller
b, err := caller.CallPost(url, "", map[string]interface{}{}) // Call the status endpoint of the peer
if err != nil {
return DEAD, map[string]int{} // If the peer is not reachable, return dead