Documentation ¶
Overview ¶
Created by xuzhuoxi on 2019-02-10. @author xuzhuoxi
Index ¶
- Constants
- func MapRPCFunction(handler *RPCHandler, key string, f func(args *RPCArgs, reply *RPCReply) error)
- func RegisterModule(m ModuleName, constructor ModuleConstructor)
- type IBaseModule
- type IModule
- type ISockState
- type ISockStateDetail
- type ModuleBase
- type ModuleConstructor
- type ModuleName
- type RPCArgs
- type RPCHandler
- type RPCReply
- type SockOwner
- type SockState
- type SockStateDetail
- func (s *SockStateDetail) AddLinkCount()
- func (s *SockStateDetail) AddReqCount()
- func (s *SockStateDetail) AddRespUnixNano(unixNano int64)
- func (s SockStateDetail) GetPassNano() int64
- func (s *SockStateDetail) ReStats()
- func (s *SockStateDetail) RemoveLinkCount()
- func (s SockStateDetail) ReqDensityTime() int
- func (s SockStateDetail) RespAvgTime() float64
- func (s SockStateDetail) RespCoefficient() float64
- func (s *SockStateDetail) Start()
- func (s SockStateDetail) StatsReqDensityTime() int
- func (s SockStateDetail) StatsRespAvgTime() float64
- func (s SockStateDetail) StatsRespCoefficient() float64
- func (s SockStateDetail) StatsWeight() float64
Constants ¶
View Source
const ( ServiceMethod_OnRPCCall = "RPCHandler.OnRPCCall" CmdRoute_OnConnected = "ModRoute.OnConnected" CmdRoute_OnDisconnected = "ModRoute.OnDisconnected" CmdRoute_UpdateState = "ModRoute.UpdateState" )
Variables ¶
This section is empty.
Functions ¶
func MapRPCFunction ¶
func MapRPCFunction(handler *RPCHandler, key string, f func(args *RPCArgs, reply *RPCReply) error)
func RegisterModule ¶
func RegisterModule(m ModuleName, constructor ModuleConstructor)
Types ¶
type IBaseModule ¶
type IBaseModule interface { GetId() string GetModuleName() string GetConfig() config.ObjectConf SetConfig(config config.ObjectConf) GetLogger() logx.ILogger }
type IModule ¶
type IModule interface { IBaseModule Init() Run() Save() OnDestroy() Destroy() }
type ISockState ¶
type ISockStateDetail ¶
type ISockStateDetail interface { //运行时间 GetPassNano() int64 //当前统计的服务权重(连接数*统计时间/统计响应时间) //越大代表压力越大 StatsWeight() float64 //响应系数(响应总时间 / (统计总时间 * 逻辑cpu数)), //注意:结果正常设置下为[0,1] RespCoefficient() float64 //平均响应时间(响应总时间/响应次数) RespAvgTime() float64 //请求密度(次数/秒) ReqDensityTime() int //区间响应系数(区间响应总时间 / (区间统计总时间 * 逻辑cpu数)), // 注意:结果正常设置下为[0,1] StatsRespCoefficient() float64 //区间平均响应时间(响应总时间/响应次数) StatsRespAvgTime() float64 //区间时间请求密度(次数/秒) StatsReqDensityTime() int }
type ModuleBase ¶
func (*ModuleBase) GetConfig ¶
func (m *ModuleBase) GetConfig() config.ObjectConf
func (*ModuleBase) GetId ¶
func (m *ModuleBase) GetId() string
func (*ModuleBase) GetLogger ¶
func (m *ModuleBase) GetLogger() logx.ILogger
func (*ModuleBase) GetModuleName ¶
func (m *ModuleBase) GetModuleName() string
func (*ModuleBase) SetConfig ¶
func (m *ModuleBase) SetConfig(config config.ObjectConf)
type ModuleConstructor ¶
type ModuleConstructor func() IModule
type ModuleName ¶
type ModuleName string
const ( ModRoute ModuleName = "route" ModGame ModuleName = "game" ModAdmin ModuleName = "admin" )
func (ModuleName) Available ¶
func (m ModuleName) Available() bool
func (ModuleName) NewModule ¶
func (m ModuleName) NewModule() IModule
type RPCHandler ¶
RPCHandler要求 全部方法必须是func(args *RPCArgs, reply *RPCReply) error 不然会报警告
func NewRPCHandler ¶
func NewRPCHandler(logger logx.ILogger) *RPCHandler
type SockOwner ¶
type SockOwner struct { //平台id PlatformId string //模块id ModuleId string //模块类型名称 ModuleName ModuleName }
Sock的拥有者信息
type SockState ¶
func (*SockState) GetSockName ¶
func (*SockState) GetSockSockConnections ¶
func (*SockState) GetSockWeight ¶
type SockStateDetail ¶
type SockStateDetail struct { SockName string //启动时间戳(纳秒) StartTimestamp int64 //最大连接数 MaxLinkCount uint64 //总请求数 TotalReqCount int64 //总响应时间 TotalRespTime int64 //最大响应时间(纳秒) MaxRespTime int64 //连接数 LinkCount uint64 //统计开始时间戳(纳秒) StatsTimestamp int64 //统计请求数 StatsReqCount int64 //统计响应时间(纳称) StatsRespUnixNano int64 //统计间隔 StatsInterval int64 // contains filtered or unexported fields }
func NewSockStateDetail ¶
func NewSockStateDetail(name string, statsInterval int64) *SockStateDetail
func (*SockStateDetail) AddRespUnixNano ¶
func (s *SockStateDetail) AddRespUnixNano(unixNano int64)
增加响应时间量
func (SockStateDetail) RespAvgTime ¶
func (s SockStateDetail) RespAvgTime() float64
平均响应时间(响应总时间/响应次数)
func (SockStateDetail) RespCoefficient ¶
func (s SockStateDetail) RespCoefficient() float64
响应系数(响应总时间/统计总时间), 注意:结果正常设置下为[0,1]
func (SockStateDetail) StatsReqDensityTime ¶
func (s SockStateDetail) StatsReqDensityTime() int
区间时间请求密度(次数/秒)
func (SockStateDetail) StatsRespAvgTime ¶
func (s SockStateDetail) StatsRespAvgTime() float64
区间平均响应时间(响应总时间/响应次数)
func (SockStateDetail) StatsRespCoefficient ¶
func (s SockStateDetail) StatsRespCoefficient() float64
区间响应系数(响应总时间/统计总时间), 注意:结果正常设置下为[0,1]
func (SockStateDetail) StatsWeight ¶
func (s SockStateDetail) StatsWeight() float64
当前统计的服务权重(连接数 + 统计响应时间 / 统计时间 ) 越大代表压力越大
Click to show internal directories.
Click to hide internal directories.