go框架
K | W | H | L |
---|---|---|---|
What do I know? | What do I want to know? | How I will learn? | What I have learned? |
我知道些什么? | 我想要知道些什么? | 我该如何去学习? | 我学到了什么? |
Know | Want | How | Learned |
目录结构? | |||
启动服务器流程? | |||
有哪些配置?负责做什么? | |||
redis数据库怎么使用? | |||
redis lua脚本怎么使用? | |||
sync.RWMutex 互斥锁怎么使用? | https://studygolang.com/pkgdoc | ||
defer 作用? | https://xiaozhou.net/something-about-defer-2014-05-25.html https://blog.csdn.net/huang_yong_peng/article/details/82950743 |
||
parser 协议解析 | |||
reflect 反射 | |||
目录
[TOC]
问题
目录结构?
xserver
–conf 配置文件,进程启动配置、秘钥key |
配置
ServerCmd: 启动进程时cmd输入的参数
message ServerCmd
{
string path = 1;
string globalPath = 2;
string logPath = 3;
string logSign = 4;
bool daemon = 5;
bool lan = 6;
}
ServerInfo
message ServerInfo
{
int32 id = 1; //服务器id
string name = 3; //服务器名称
string cmdAddr = 4; //命令行绑定地址
string rpcAddr = 5; //rpc绑定地址
string extAddr = 6; //对外服务器地址
int64 lastTick = 7; //最后心跳
string type = 8;
int32 load = 9; //负载
string conf = 10;//配置文件
int32 onlineCount = 11;//在线玩家
string md5 = 12;
string pbVer = 13;
}
message ServerWarn
{
repeated int32 badRpc = 1;
int64 lastPanic = 2;
int32 panicCount = 3;
bool goScale = 4;//goroutine比例是否失衡
}
Config
Server *configServer
Global *configGlobal
Doc *ConfigDoc
//服务器配置
type configServer struct {
Id int32
Type string
Name string
Net *configServerNet
Subscribe []int32
}
//服务器网络配置
type configServerNet struct {
Rpc string
Cmd string
Ext string
ExtIpUrl string
Timeout int
}
type configGlobal struct {
LoginVersion string //登陆版本
LoginVersionSwitch bool //版本检查开关
GamerCountPerRedis int32 //每台redis玩家数量
LoginSessionTimeout int32 //登陆session保存时间
MaxCacheGamer int32 //最大缓存玩家数量
MinGamerId int32
NeedCDKSwitch bool //cdk开关
ProfSwitch bool //性能监视开关
LogUploadUrl string //日志上传url
LogFormField string //日志上传filed
HTTPLogUploadUrl string //HTTP日志上传url
MsgqueCountBuffer int32 //msgque缓冲数量
GoroutineCountBuffer int32 //goroutin缓冲数量
RedisPoolSize int32 //redis链接池大小
Timezone int32 //时区
Redis []string //redis
FastAuthWhiteList []string
FastAuthCheckSwitch bool
Proto string
LogLevel string //日志等级
MaxLogFileSize int //日志文件最大size,单位MB
SSLCrtPath string
SSLKeyPath string
WWWDir string //www文件目录
WWWUrl string //wwwurl路径
Compress bool
Pvp *configPVP
WXId string
WXSec string
GMSwitch bool //GM开关
}
type configPVP struct {
PvpMaxObSize int
PvpFrameDelta int
PvpMinFrameDelta int
PvpFrameDeltaScale int
PvpThreadRecv bool
PvpInputDelta int
PvpStartWaitTimeout int
PvpAllAIExit bool
PvpResultCheck bool
PvpMaxKeepTime int
}