Configuration NATS

This commit is contained in:
mr
2026-01-27 09:35:47 +01:00
parent 802786daa7
commit 643beacd4b
3 changed files with 63 additions and 34 deletions

View File

@@ -61,7 +61,7 @@ func (s State) String() string {
type API struct{}
func (a *API) Discovered(infos []*beego.ControllerInfo) {
respondToDiscovery := func(m map[string]interface{}) {
respondToDiscovery := func(m map[string]string) {
if len(m) == 0 {
a.SubscribeRouter(infos)
}
@@ -91,8 +91,10 @@ func (a *API) GetState() (State, int, error) {
return ALIVE, 200, nil // If everything is up, return alive
}
func (a *API) ListenRouter(exec func(msg map[string]interface{})) {
go NewNATSCaller().ListenNats(DISCOVERY.GenerateKey("api"), exec)
func (a *API) ListenRouter(exec func(msg map[string]string)) {
go NewNATSCaller().ListenNats(DISCOVERY.GenerateKey(), map[NATSMethod]func(msg map[string]string){
DISCOVERY: exec,
})
}
func (a *API) SubscribeRouter(infos []*beego.ControllerInfo) {