hpds_net_framework/data.go

55 lines
1.4 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package hpds_net_framework
import "C"
import "sync"
var (
// Cfg is the config instance
Cfg *Data
once sync.Once
)
// Data is the config struct
type Data struct {
// 单个连接未处理消息包缓存队列大小
// 注意:[超过这个大小包将丢弃视为当前系统无法处理默认100]
ConnUndoQueueSize int
// 单个连接未写入消息包队列大小 [超过这个大小包将丢弃视为当前系统无法处理默认为1]
ConnWriteQueueSize int
// 第一个包等待超市时间 (s) [默认5秒连接上来未读到正确包断开连接]
FirstPackageTimeout int
// 连接读取超时(s) [默认35秒, 超时等待时间内,请发送任何数据包,如心跳包]
ConnReadTimeout int
// 连接写超时(s) [默认5秒, 超时等待时间内,请发送任何数据包,如心跳包]
ConnWriteTimeout int
// 数据包最大限制,[默认2048]
MaxDataPackageSize int
// ws 最大header[默认1024]
MaxHeaderLen int
}
func init() {
Cfg = &Data{
ConnUndoQueueSize: 100,
ConnWriteQueueSize: 10,
FirstPackageTimeout: 5,
ConnReadTimeout: 35,
ConnWriteTimeout: 5,
MaxDataPackageSize: 4096,
MaxHeaderLen: 1024,
}
}
// SetConf this before startup server
func SetConf(cfg *Data) {
once.Do(func() {
Cfg = cfg
if C.ConnUndoQueueSize == 0 {
C.ConnUndoQueueSize = 1
}
if C.ConnWriteQueueSize == 0 {
C.ConnWriteQueueSize = 1
}
})
}