MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / subscribe

Function subscribe

IceFireDB-Redis-Proxy/pkg/router/pubsub.go:51–70  ·  view source on GitHub ↗
(router IRoutes, pubSub *p2p.PubSub)

Source from the content-addressed store, hash-verified

49}
50
51func subscribe(router IRoutes, pubSub *p2p.PubSub) {
52 utils.GoWithRecover(func() {
53 for args := range pubSub.Inbound {
54 // logrus.Info("inbound: ", args.Message)
55 var data []interface{}
56 err := json.Unmarshal([]byte(args.Message), &data)
57 if err != nil {
58 logrus.Errorf("subscribe error: %v", err)
59 continue
60 }
61 err = router.Sync(data)
62 if err != nil {
63 logrus.Errorf("subscribe sync error: %v", err)
64 }
65 }
66 }, func(r interface{}) {
67 time.Sleep(time.Second)
68 subscribe(router, pubSub)
69 })
70}

Callers 1

PubSubMiddlewareFunction · 0.70

Calls 2

GoWithRecoverFunction · 0.92
SyncMethod · 0.65

Tested by

no test coverage detected