MCPcopy Create free account
hub / github.com/Super-long/ChubbyGo / ServerConfig

Struct ServerConfig

Connect/server_handler.go:37–56  ·  view source on GitHub ↗

第一版的创建连接还是需要服务器之间都确定对方的IP,客户端也需要知道服务器的地址 TODO 后面可以改成类似redis,通过消息的交互得到其他节点的存在

Source from the content-addressed store, hash-verified

35// TODO 后面可以改成类似redis,通过消息的交互得到其他节点的存在
36
37type ServerConfig struct {
38 peers []*rpc.Client // 表示其他几个服务器的连接句柄
39 me uint64 // 后面改成全局唯一ID
40 nservers int // 表示一共有多少个服务器
41 kvserver *BaseServer.RaftKV // 一个raftkv实体
42 persister *Persister.Persister // 持久化实体
43 mu sync.Mutex // 用于保护本结构体的变量
44 // 不设置成大写没办法从配置文件中读出来
45 MaxRaftState int `json:"maxraftstate"` // raft层日志压缩上限
46 Maxreries int `json:"maxreries"` // 超时重连最大数
47 ServersAddress []string `json:"servers_address"` // 读取配置文件中的其他服务器地址
48 MyPort string `json:"myport"` // 自己的端口号
49 TimeOutEntry int `json:"timeout_entry"` // connectAll中定义的重传超时间隔 单位为毫秒
50 // 这三个要在解析完以后传给persister
51 // 后缀hdb全称为 "Honeycomb Database Backup file" 蜂巢数据备份文件
52 SnapshotFileName string `json:"snapshotfilename"` // 快照的持久化文件名
53 RaftstateFileName string `json:"raftstatefilename"` // raft状态的持久化名
54 PersistenceStrategy string `json:"persistencestrategy"`// 对应着三条策略 见persister.go 注意配置文件中不能拼写错误
55 ChubbyGoMapStrategy string `json:"chubbygomapstrategy"`// 对应两条策略:syncmap,concurrentmap;详细见chubbygomap.go
56}
57
58/*
59 * @brief: 拿到其他服务器的地址,分别建立RPC连接

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected