xconf

package
v0.0.0-...-a183791 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ServerModeTcp       = "tcp"
	ServerModeWebsocket = "websocket"
)
View Source
const (
	WorkerModeHash = "Hash" // 默认使用取余的方式
	WorkerModeBind = "Bind" // 为每个连接分配一个worker
)

Variables

This section is empty.

Functions

func PathExists

func PathExists(path string) (bool, error)

PathExists 判断一个文件是否存在

func UserConfToGlobal

func UserConfToGlobal(config *Config)

UserConfToGlobal 注意如果使用UserConf应该调用方法同步至 GlobalConfObject 因为其他参数是调用的此结构体参数

Types

type Config

type Config struct {
	Host              string // 当前服务器主机IP
	TCPPort           int    // 当前服务器主机监听端口号
	WsPort            int    // 当前服务器主机websocket监听端口
	Name              string // 当前服务器名称
	Version           string // 当前版本号
	MaxPacketSize     uint32 // 读写数据包的最大值
	MaxConn           int    // 当前服务器主机允许的最大链接个数
	WorkerPoolSize    uint32 // 业务工作Worker池的数量
	MaxWorkerTaskLen  uint32 // 业务工作Worker对应负责的任务队列最大任务存储数量
	WorkerMode        string // 为链接分配worker的方式
	MaxMsgChanLen     uint32 // SendBuffMsg发送消息的缓冲最大长度
	IOReadBuffSize    uint32 // 每次IO最大的读取长度
	Mode              string // "tcp":tcp监听, "websocket":websocket 监听 为空时同时开启
	RouterSlicesMode  bool   // 路由模式 false为旧版本路由,true为启用新版本的路由 默认使用旧版本
	LogDir            string // 日志所在文件夹 默认"./log"
	LogFile           string // 日志文件名称   默认""  --如果没有设置日志文件,打印信息将打印至stderr
	LogSaveDays       int    // 日志最大保留天数
	LogFileSize       int64  // 日志单个日志最大容量 默认 64MB,单位:字节,记得一定要换算成MB(1024 * 1024)
	LogCons           bool   // 日志标准输出  默认 false
	LogIsolationLevel int    // 日志隔离级别  -- 0:全开 1:关debug 2:关debug/info 3:关debug/info/warn ...
	HeartbeatMax      int    // 最长心跳检测间隔时间(单位:秒),超过改时间间隔,则认为超时,从配置文件读取
	CertFile          string //  证书文件名称 默认""
	PrivateKeyFile    string //  私钥文件名称 默认"" --如果没有设置证书和私钥文件,则不启用TLS加密
}

Config

存储一切有关框架的全局参数,供其他模块使用 一些参数也可以通过 用户根据 fastnet2.json来配置

var GlobalObject *Config

GlobalObject 定义一个全局的对象

func (*Config) HeartbeatMaxDuration

func (g *Config) HeartbeatMaxDuration() time.Duration

func (*Config) InitLogConfig

func (g *Config) InitLogConfig()

func (*Config) Reload

func (g *Config) Reload()

Reload 读取用户的配置文件

func (*Config) Show

func (g *Config) Show()

Show 打印配置信息

Jump to

Keyboard shortcuts

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