基于serf的数据库同步模块库
liuxiaolong
2019-10-08 0b3b1aecb4a2a26f8797ea62af2b5a0381962ad5
dbself.go
@@ -6,7 +6,6 @@
   "os"
   "os/exec"
   "path/filepath"
   "strconv"
   "strings"
   "sync"
   "github.com/jinzhu/gorm"
@@ -131,32 +130,6 @@
      return true,nil
   }
   return false,errors.New("localDb is nil")
}
type SyncSerf struct {
   LamportTime string `json:"lamport_time"`
}
func QueryLTimeFromDbByGorm() uint64 {
   if localDb != nil {
      var syncSerf []SyncSerf
      err := localDb.Raw("select * from sync_serf").Scan(&syncSerf).Error
      if err == nil && len(syncSerf) > 0 {
         ltStr := syncSerf[0].LamportTime
         logger.Info("db.LamportTime str:", ltStr)
         t, e := strconv.ParseUint(ltStr, 10, 64)
         if e != nil {
            logger.Error("db.LamportTime parseUint err:", e)
         } else {
            curLTime = t
         }
         logger.Info("db.LamportTime:", ltStr)
      } else {
         logger.Error("get db.LamportTime err:", err)
      }
   }
   return 0
}
type TableDesc struct {