imodule

package
v0.0.0-...-eba1a7b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 6, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Created by xuzhuoxi on 2019-02-10. @author xuzhuoxi

Index

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 ISockState interface {
	GetSockName() string
	GetSockSockConnections() uint64
	GetSockWeight() float64
}

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

type ModuleBase struct {
	Logger logx.ILogger
	// contains filtered or unexported fields
}

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 RPCArgs

type RPCArgs struct {
	From string
	Cmd  string
	Data [][]byte
}

type RPCHandler

type RPCHandler struct {
	Logger logx.ILogger
	// contains filtered or unexported fields
}

RPCHandler要求 全部方法必须是func(args *RPCArgs, reply *RPCReply) error 不然会报警告

func NewRPCHandler

func NewRPCHandler(logger logx.ILogger) *RPCHandler

func (*RPCHandler) OnRPCCall

func (g *RPCHandler) OnRPCCall(args *RPCArgs, reply *RPCReply) error

type RPCReply

type RPCReply struct {
	To   string
	Cmd  string
	Data [][]byte
}

type SockOwner

type SockOwner struct {
	//平台id
	PlatformId string
	//模块id
	ModuleId string
	//模块类型名称
	ModuleName ModuleName
}

Sock的拥有者信息

type SockState

type SockState struct {
	//名称
	SockName string
	//连接数
	SockConnections uint64
	//压力
	SockWeight float64
}

func (*SockState) GetSockName

func (ss *SockState) GetSockName() string

func (*SockState) GetSockSockConnections

func (ss *SockState) GetSockSockConnections() uint64

func (*SockState) GetSockWeight

func (ss *SockState) GetSockWeight() float64

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) AddLinkCount

func (s *SockStateDetail) AddLinkCount()

增加一个连接

func (*SockStateDetail) AddReqCount

func (s *SockStateDetail) AddReqCount()

增加一个请求

func (*SockStateDetail) AddRespUnixNano

func (s *SockStateDetail) AddRespUnixNano(unixNano int64)

增加响应时间量

func (SockStateDetail) GetPassNano

func (s SockStateDetail) GetPassNano() int64

启动时间

func (*SockStateDetail) ReStats

func (s *SockStateDetail) ReStats()

重新统计

func (*SockStateDetail) RemoveLinkCount

func (s *SockStateDetail) RemoveLinkCount()

减少一个连接

func (SockStateDetail) ReqDensityTime

func (s SockStateDetail) ReqDensityTime() int

时间请求密度(次数/秒)

func (SockStateDetail) RespAvgTime

func (s SockStateDetail) RespAvgTime() float64

平均响应时间(响应总时间/响应次数)

func (SockStateDetail) RespCoefficient

func (s SockStateDetail) RespCoefficient() float64

响应系数(响应总时间/统计总时间), 注意:结果正常设置下为[0,1]

func (*SockStateDetail) Start

func (s *SockStateDetail) Start()

启动

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

当前统计的服务权重(连接数 + 统计响应时间 / 统计时间 ) 越大代表压力越大

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL