package pub import ( "basic.com/pubsub/protomsg.git" "github.com/gogo/protobuf/proto" ) type pubUtil struct { topic string publish func(string, []byte) error } var putil = pubUtil{} func InitPub(topic string, f func(string, []byte) error) { putil.topic = topic if f != nil { putil.publish = f } } func AddDbMessage(msg *protomsg.DbChangeMessage) { if putil.topic != "" && putil.publish != nil { bts, err := proto.Marshal(msg) if err == nil { putil.publish(putil.topic, bts) } } }