| | |
| | | package syncdb |
| | | |
| | | import ( |
| | | "context" |
| | | "fmt" |
| | | "net" |
| | | "os" |
| | |
| | | ReplayOnJoinDefault = false |
| | | SnapshotPathDefault = "./serfSnapShot" |
| | | MaxEventBufferCount = 2048 |
| | | |
| | | TcpTransportPort = 30194 //tcp传输大数据量接口 |
| | | ) |
| | | |
| | | // DefaultConfig default config |
| | |
| | | } |
| | | } |
| | | |
| | | func (c *Config) MergeConf(s *Config) { |
| | | if s != nil { |
| | | if s.Ctx != nil { |
| | | c.Ctx = s.Ctx |
| | | } else { |
| | | c.Ctx = context.Background() |
| | | } |
| | | c.BindAddr = s.BindAddr |
| | | c.RPCAddr = s.RPCAddr |
| | | c.RPCPort = s.RPCPort |
| | | //serf快照地址 |
| | | if s.SnapshotPath != "" { |
| | | c.SnapshotPath = s.SnapshotPath |
| | | } |
| | | if s.EncryptKey != "" { |
| | | //报文加密的key |
| | | c.EncryptKey = s.EncryptKey |
| | | } |
| | | if s.RPCAuthKey != "" { |
| | | //RPC认证的key |
| | | c.RPCAuthKey = s.RPCAuthKey |
| | | } |
| | | } |
| | | } |
| | | |
| | | // Config struct |
| | | type Config struct { |
| | | // config from serf agent |
| | | *agent.Config |
| | | Mode string `json:"mode"` |
| | | Mode string `json:"mode"` |
| | | |
| | | // name to group members into cluster |
| | | ClusterID string `json:"cluster_name"` |
| | | ClusterID string `json:"cluster_name"` |
| | | |
| | | // port to communicate between cluster members |
| | | ClusterPort int `yaml:"cluster_port"` |
| | | RPCPort int `yaml:"-"` |
| | | ClusterPort int `yaml:"cluster_port"` |
| | | RPCPort int `yaml:"-"` |
| | | Ctx context.Context |
| | | } |
| | | |
| | | // readConfigFile reads configuration from config file |