增加第一个简版的轮询负载均衡

This commit is contained in:
2021-10-19 14:48:46 +08:00
parent 3aaffbeab2
commit 75b557b07f
6 changed files with 178 additions and 2 deletions

19
balance/define/base.go Normal file
View File

@ -0,0 +1,19 @@
// Package define...
//
// Description : define...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2021-10-19 12:43 下午
package define
const (
// ServerNodeStatusNormal 服务节点状态正常
ServerNodeStatusNormal = 0
// ServerNodeStatusLoss 探活逻辑无法和服务建立连接
ServerNodeStatusLoss = 1
// ServerNodeStatusException 指定时间区间内出现过多 5xx
ServerNodeStatusException = 2
// ServerNodeStatusRemove 通过调用函数的方法,将节点移除
ServerNodeStatusRemove = 3
)

20
balance/define/node.go Normal file
View File

@ -0,0 +1,20 @@
// Package define...
//
// Description : define...
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 2021-10-19 12:36 下午
package define
// ServerNode 服务器节点的定义
//
// Author : go_developer@163.com<白茶清欢>
//
// Date : 12:36 下午 2021/10/19
type ServerNode struct {
HostIP string `json:"host_ip"` // 机器IP
Port int `json:"port"` // 机器端口
Status int `json:"status"` // 机器状态
Weight int `json:"weight"` // 机器权重
}