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

Function subscribe

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

Source from the content-addressed store, hash-verified

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

Callers 1

PubSubMiddlewareFunction · 0.70

Calls 2

GoWithRecoverFunction · 0.92
SyncMethod · 0.65

Tested by

no test coverage detected