Daemons Search

This commit is contained in:
mr
2026-01-28 17:22:29 +01:00
parent 0ed2fc0f15
commit 7fd258dc9d
22 changed files with 1631 additions and 680 deletions

47
daemons/pubsub/nats.go Normal file
View File

@@ -0,0 +1,47 @@
package pubsub
import (
"context"
"encoding/json"
"fmt"
"cloud.o-forge.io/core/oc-lib/tools"
)
func ListenNATS() {
tools.NewNATSCaller().ListenNats(map[tools.NATSMethod]func(tools.NATSResponse){
tools.PROPALGATION_EVENT: func(resp tools.NATSResponse) {
var propalgation tools.PropalgationMessage
err := json.Unmarshal(resp.Payload, &propalgation)
var dt *tools.DataType
if propalgation.DataType > 0 {
dtt := tools.DataType(propalgation.DataType)
dt = &dtt
}
if err == nil {
switch propalgation.Action {
case tools.PB_CREATE:
case tools.PB_UPDATE:
case tools.PB_DELETE:
GetPubSubService().ToPartnerPublishEvent(
context.Background(),
propalgation.Action,
dt, propalgation.User,
propalgation.Payload,
)
case tools.PB_SEARCH:
m := map[string]interface{}{}
json.Unmarshal(propalgation.Payload, &m)
GetPubSubService().SearchPublishEvent(
context.Background(),
dt,
fmt.Sprintf("%v", m["type"]),
propalgation.User,
fmt.Sprintf("%v", m["search"]),
)
}
}
},
})
}