代码拉取完成,页面将自动刷新
package serverMgr
import (
"sync/atomic"
"gitee.com/night-tc/gobige/global"
"gitee.com/night-tc/gobige/msgdef/protomsg"
)
/*
服务器信息
*/
type IServerInfo interface {
//服务器组ID
GetGroupID() uint32
//服务器ID
GetServerID() uint64
//服务器类型
GetSrvType() uint32
//服务器公共组ID
GetOthGroupID() uint32
//Token
GetToken() string
//获取指定类型的连接地址
GetListenAdd(v string) string
// 服务器繁忙数值 0到100,100表示很忙
GetLoad() int64
// 设置服务器繁忙数值
SetLoad(v int64)
// 服务器状态
GetStatus() protomsg.ServerStatus
// 设置服务器状态
SetStatus(v int32)
}
// 注册在etcd中的服务器信息,上层可以组合它实现IServerInfo,实现自定义注册数据
type ServerInfo struct {
Number uint64 //线编号
ServerID uint64 //服务器ID
SrvType global.ServerTypeEnum //服务器类型
GroupID uint32 //服务器组ID
OthGroupID uint32 //对应公共组ID
ListenMap map[string]string //地址信息
Token string //链接过去用来验证的Token
Load int64 //服务器繁忙数值 0到100,100表示很忙
Status int32 // protomsg.ServerStatus
}
// 服务器组ID
func (this *ServerInfo) GetGroupID() uint32 {
return this.GroupID
}
// 服务器ID
func (this *ServerInfo) GetServerID() uint64 {
return this.ServerID
}
// 服务器类型
func (this *ServerInfo) GetSrvType() uint32 {
return this.SrvType
}
// 服务器公共组ID
func (this *ServerInfo) GetOthGroupID() uint32 {
return this.OthGroupID
}
// Token
func (this *ServerInfo) GetToken() string {
return this.Token
}
// 获取指定类型的连接地址
func (this *ServerInfo) GetListenAdd(v string) string {
return this.ListenMap[v]
}
// 服务器繁忙数值 0到100,100表示很忙
func (this *ServerInfo) GetLoad() int64 {
return atomic.LoadInt64(&this.Load)
}
// 设置服务器繁忙数值
func (this *ServerInfo) SetLoad(v int64) {
atomic.StoreInt64(&this.Load, v)
}
func (this *ServerInfo) GetStatus() protomsg.ServerStatus {
return protomsg.ServerStatus(this.Status)
}
func (this *ServerInfo) SetStatus(v int32) {
atomic.StoreInt32(&this.Status, v)
}
// // 服务一个副本出来
// func (this *ServerInfo) Copy() IServerInfo {
// result := ServerInfo{}
// result = *this
// return &result
// }
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。