基于serf的数据库同步模块库
chenshijun
2019-10-12 164c94a4d82ccad8277b1c2dcb32943102d846aa
config.go
@@ -20,7 +20,6 @@
   "fmt"
   "net"
   "strconv"
   //"github.com/apache/servicecomb-service-center/syncer/pkg/utils"
   "github.com/hashicorp/memberlist"
   "github.com/hashicorp/serf/cmd/serf/command/agent"
@@ -46,7 +45,10 @@
   MaxQuerySize       = 50 * 1024 * 1024
   MaxUserEventSize   = 5 * 1024
   ReplayOnJoinDefault = false
   SnapshotPathDefault = "/opt/vasystem/serfSnapShot"
   SnapshotPathDefault = "./serfSnapShot"
   MaxEventBufferCount = 2048
   TcpTransportPort = 30194 //tcp传输大数据量接口
)
// DefaultConfig default config
@@ -87,7 +89,7 @@
}
// convertToSerf convert Config to serf.Config
func (c *Config) convertToSerf() (*serf.Config, error) {
func (c *Config) convertToSerf(snapshotPath string) (*serf.Config, error) {
   serfConf := serf.DefaultConfig()
   bindIP, bindPort, err := SplitHostPort(c.BindAddr, DefaultBindPort)
@@ -120,13 +122,19 @@
   if c.Mode == ModeCluster && c.RetryMaxAttempts <= 0 {
      c.RetryMaxAttempts = retryMaxAttempts
   }
   c.SnapshotPath = SnapshotPathDefault
   if snapshotPath != "" {
      c.SnapshotPath = snapshotPath
   }
   c.ReplayOnJoin = ReplayOnJoinDefault
   serfConf.QueryResponseSizeLimit = c.QueryResponseSizeLimit
   serfConf.QuerySizeLimit = c.QuerySizeLimit
   serfConf.UserEventSizeLimit = c.UserEventSizeLimit
   serfConf.SnapshotPath = c.SnapshotPath
   serfConf.EventBuffer = MaxEventBufferCount
   return serfConf, nil
}