zconf

package
v0.0.0-...-ef14408 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package utils 提供zinx相关工具类函数 包括:

全局配置
配置文件加载

当前文件描述: @Title globalobj.go @Description 相关配置文件定义及加载方式 @Author Aceld - Thu Mar 11 10:32:29 CST 2019

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PathExists

func PathExists(path string) (bool, error)

PathExists 判断一个文件是否存在

func UserConfToGlobal

func UserConfToGlobal(config *Config)

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

Types

type Config

type Config struct {
	/*
		Server
	*/
	Host    string //当前服务器主机IP
	TCPPort int    //当前服务器主机监听端口号
	Name    string //当前服务器名称

	/*
		Zinx
	*/
	Version          string //当前Zinx版本号
	MaxPacketSize    uint32 //读写数据包的最大值
	MaxConn          int    //当前服务器主机允许的最大链接个数
	WorkerPoolSize   uint32 //业务工作Worker池的数量
	MaxWorkerTaskLen uint32 //业务工作Worker对应负责的任务队列最大任务存储数量
	MaxMsgChanLen    uint32 //SendBuffMsg发送消息的缓冲最大长度
	IOReadBuffSize   uint32 //每次IO最大的读取长度

	/*
		logger
	*/
	LogDir            string //日志所在文件夹 默认"./log"
	LogFile           string //日志文件名称   默认""  --如果没有设置日志文件,打印信息将打印至stderr
	LogIsolationLevel int    //日志隔离级别  -- 0:全开 1:关debug 2:关debug/info 3:关debug/info/warn ...

	/*
		Keepalive
	*/
	HeartbeatMax int //最长心跳检测间隔时间(单位:秒),超过改时间间隔,则认为超时,从配置文件读取

	/*
		TLS
	*/
	CertFile       string // 证书文件名称 默认""
	PrivateKeyFile string // 私钥文件名称 默认"" --如果没有设置证书和私钥文件,则不启用TLS加密
}

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

var GlobalObject *Config

定义一个全局的对象

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

提示详细

Jump to

Keyboard shortcuts

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