You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nnet/config/config.go

45 lines
1.2 KiB
Go

1 year ago
package config
import (
"git.noahlan.cn/noahlan/ntools-go/core/pool"
"time"
)
const (
// DevMode means development mode.
DevMode = "dev"
// TestMode means test mode.
TestMode = "test"
// ProductionMode means production mode.
ProductionMode = "prod"
)
type (
EngineConf struct {
1 year ago
ServerConf
Pool pool.Config
}
ServerConf struct {
// Protocol 协议名
// "tcp", "tcp4", "tcp6", "unix" or "unixpacket"
// 若只想开启IPv4, 使用tcp4即可
1 year ago
Protocol string `json:",default=tcp4"`
// Addr 服务地址
// 地址可直接使用hostname,但强烈不建议这样做,可能会同时监听多个本地IP
// 如果端口号不填或端口号为0例如"127.0.0.1:" 或 ":0",服务端将选择随机可用端口
1 year ago
Addr string `json:",default=0.0.0.0"`
// Name 服务端名称默认为n-net
1 year ago
Name string `json:",default=n-net"`
// TaskTimerPrecision // 全局任务的timer间隔
TaskTimerPrecision time.Duration `json:",default=1s"`
// Mode 运行模式
1 year ago
Mode string `json:",default=dev,options=[dev,test,prod]"`
}
)
// ShallLogDebug 是否应该打印 Debug 级别的日志,打印的首要条件是 nlog 的打印级别为 debug
func ShallLogDebug(mode string) bool {
return mode == DevMode || mode == TestMode
}