liuxiaolong
2020-03-12 0c9642be9fb9ed7efa5330d67551bb78b47e0d10
pubsub.go
@@ -2,27 +2,37 @@
type PubSub interface {
   Publish([]byte)
   Publish(Message)
   Surveyor() []string
   Recv() chan Message
   GetCliInfo() map[string][]byte
   SetResp([]byte)
}
type Message struct {
   Id string
   Topic string
   Msg []byte
}
const (
   Topic_Camera = "camera"  //摄像机消息
   Topic_Camera = "camera"  //摄像机解码消息
   Topic_StackDecode = "stackDecode" //数据栈解码消息
   Topic_Task = "task" //任务消息
   Topic_Sdk = "sdk" //算法消息
    Topic_RuleProc = "ruleProcess" //ruleProcess消息
   Topic_Event = "event" //事件消息
)
func NewPublisher(url string,mode int) (PubSub,error) {
   return newPub(url)
func NewPublisher(url string,heartBeatUrl string,mode int) (PubSub,error) {
   return newPub(url,heartBeatUrl)
}
func NewSubscriber(url string,mode int,topics []string) (PubSub,error) {
   return newSub(url, topics)
}
//processId is process Identifier,unique
func NewSubscriber(url string,heartBeatUrl string,mode int,topics []string,processId string) (PubSub,error) {
   return newSub(url,heartBeatUrl, topics, processId)
}