Documentation ¶
Overview ¶
封装API常用方法
数据同步需要注意的是: leader只有在通知完所有follower更新完数据之后,自身才会进行数据更新 因此leader
数据同步需要注意的是,必须在节点完成election选举之后才能进行数据通信。 也就是说repl通信需要建立在raft成功作为前提
数据同步需要注意的是: leader只有在通知完所有follower更新完数据之后,自身才会进行数据更新 因此leader
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Node ¶
type Node struct { Group string // 集群名称 Id string // 节点ID(根据算法自动生成的集群唯一名称) Name string // 节点主机名称 Ip string // 主机节点的ip,由通信的时候进行填充, // 一个节点可能会有多个IP,这里保存最近通信的那个,节点唯一性识别使用的是Name字段 CfgFilePath string // 配置文件绝对路径 CfgReplicated bool // 本地配置对象是否已同步到leader(配置同步需要注意覆盖问题) Peers *gmap.StringInterfaceMap // 集群所有的节点信息(ip->节点信息),不包含自身 Role int32 // 集群角色 RaftRole int32 // RAFT角色 Leader *NodeInfo // Leader节点信息 MinNode int32 // 最小节点数 Score int64 // 选举比分 ScoreCount int32 // 选举比分的节点数 ElectionDeadline int64 // 选举超时时间点 AutoScan bool // 启动时自动扫描局域网,添加dister节点 LogIdIndex int64 // 用于生成LogId的参考字段 LastLogId int64 // 最后一次保存log的id,用以数据一致性判断 LastServiceLogId int64 // 最后一次保存的service id号,用以识别本地Service数据是否已更新,不做Leader与Follower的同步数据 LogList *glist.SafeList // 日志列表,用以存储临时的消息日志,以便快速进行数据同步到其他节点,仅在Leader节点存储 ServiceList *glist.SafeList // Service同步事件列表,用以Service同步 SavePath string // 物理存储的本地数据*目录*绝对路径 Service *gmap.StringInterfaceMap // 存储的服务配置表 DataMap *gmap.StringStringMap // 存储的K-V哈希表 // contains filtered or unexported fields }
服务器节点信息
func (*Node) SendToLeader ¶
向leader发送操作请求,并返回执行结果
type NodeApiBalance ¶
type NodeApiBalance struct {
// contains filtered or unexported fields
}
用于Service 负载均衡API接口的对象
func (*NodeApiBalance) Get ¶
func (this *NodeApiBalance) Get(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
负载均衡查询
type NodeApiKv ¶
type NodeApiKv struct {
// contains filtered or unexported fields
}
用于KV API接口的对象
func (*NodeApiKv) Delete ¶
func (this *NodeApiKv) Delete(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
K-V 删除
func (*NodeApiKv) Get ¶
func (this *NodeApiKv) Get(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
K-V 查询
func (*NodeApiKv) Post ¶
func (this *NodeApiKv) Post(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
K-V 新增/修改
type NodeApiNode ¶
type NodeApiNode struct {
// contains filtered or unexported fields
}
用于Node API接口的对象
func (*NodeApiNode) Delete ¶
func (this *NodeApiNode) Delete(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
删除Peer
func (*NodeApiNode) Get ¶
func (this *NodeApiNode) Get(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
查询Peers
func (*NodeApiNode) Post ¶
func (this *NodeApiNode) Post(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
新增/修改Peer
type NodeApiService ¶
type NodeApiService struct {
// contains filtered or unexported fields
}
用于Service API接口的对象
func (*NodeApiService) Delete ¶
func (this *NodeApiService) Delete(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
Service 删除
func (*NodeApiService) Get ¶
func (this *NodeApiService) Get(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
Service 查询
func (*NodeApiService) Post ¶
func (this *NodeApiService) Post(s *ghttp.Server, r *ghttp.ClientRequest, w *ghttp.ServerResponse)
Service 新增/修改
type NodeInfo ¶
type NodeInfo struct { Name string `json:"name"` Group string `json:"group"` Id string `json:"id"` Ip string `json:"ip"` Status int32 `json:"status"` Role int32 `json:"role"` RaftRole int32 `json:"raft"` LastLogId int64 `json:"logid"` LastServiceLogId int64 `json:"serviceid"` Version string `json:"version"` }
节点信息
type PriorityNode ¶
type PriorityNode struct {
// contains filtered or unexported fields
}
用于负载均衡计算的结构体
type ServiceConfig ¶
type ServiceConfig struct { Name string `json:"name"` Type string `json:"type"` Node []map[string]interface{} `json:"node"` }
服务信息配置对象(用于配置结构)
Source Files ¶
- dister.go
- dister_cmd.go
- dister_server.go
- dister_server_api.go
- dister_server_api_balance.go
- dister_server_api_kv.go
- dister_server_api_node.go
- dister_server_api_service.go
- dister_server_raft_election.go
- dister_server_raft_handler.go
- dister_server_raft_heartbeat.go
- dister_server_repl_autosave.go
- dister_server_repl_handler.go
- dister_server_repl_heartbeat.go
- dister_server_repl_service.go
Click to show internal directories.
Click to hide internal directories.