chenshijun
2019-07-27 b5560d3cae1164f016ca9339592eda6b9008fb9f
util/sqlite.go
@@ -1,12 +1,11 @@
package util
import (
    "flag"
   "basic.com/pubsub/protomsg.git"
   "basic.com/dbapi.git"
   "github.com/gogo/protobuf/proto"
   "basic.com/pubsub/protomsg.git"
    "basic.com/valib/gopherdiscovery.git"
   "flag"
   "github.com/gogo/protobuf/proto"
    "taskpubsub/logger"
)
@@ -42,9 +41,7 @@
var newsdkmsg = &protomsg.DbChangeMessage{}
func processinit(initchan chan bool) {
func initDbData(initchan chan bool) {
   CameraIds = camval.FindAll()
   logger.Info("==============camera camera with task ================")
@@ -58,7 +55,7 @@
   initchan <- true
}
func Getdata(opt []byte) {
func updateDbData(opt []byte) {
   if err := proto.Unmarshal(opt, newsdkmsg); err != nil {
      logger.Error("publichshMessage ", err)
      return
@@ -96,14 +93,14 @@
func Init(initchan chan bool) {
    dbapi.Init(*dbip, *dbport)
   clientOne, _ := gopherdiscovery.ClientWithSub(*urlServer, *urlPubSub, "ip:local")
   recvinit := clientOne.HeartBeatMsg()
   client, _ := gopherdiscovery.ClientWithSub(*urlServer, *urlPubSub, "ip:local")
   recvinit := client.HeartBeatMsg()
   _ = <-recvinit
   processinit(initchan)
   initDbData(initchan)
   peers, _ := clientOne.Peers()
   peers, _ := client.Peers()
   for x := range peers {
      Getdata(x)
      updateDbData(x)
   }
}