Documentation
¶
Index ¶
- Constants
- Variables
- func Abs(dir ...string) string
- func Close() bool
- func Debug() bool
- func Dir() string
- func Exist(name string) bool
- func Name() string
- func On(e EventType, f EventFunc)
- func Range(f func(Module) bool)
- func SIGHUP()
- func SetBanner(f func())
- func SetProcess(f func() bool)
- func Start(waitForSystemExit bool, mods ...Module)
- func Use(mods ...Module)
- func WaitForSystemExit()
- type EventFunc
- type EventType
- type Module
- type Reload
Constants ¶
View Source
const ( AppName string = "name" AppPprof string = "pprof" AppDebug string = "debug" AppBinDir string = "bin" //程序目录 AppWorkerDir string = "dir" //工作目录 AppConfigNamePidFile string = "pid" //pid file dir AppConfigNameLogsPath string = "logs.path" //logs dir AppConfigNameLogsLevel string = "logs.level" //logs level AppConfigNameConfigFileExt string = "ConfigFileExt" //config file default ext name,只能在程序中设置 AppConfigNameConfigFileName string = "config" //config file )
View Source
const LoggerFileName = "file"
Variables ¶
View Source
var Config = &config{Viper: viper.New()}
View Source
var GCSummaryTime time.Duration = time.Second * 300
GCSummaryTime 报告性能摘要时间间隔
View Source
var Options = &struct { Banner func() Process func() bool //设置启动进程,返回false时不会继续向下执行 }{ Banner: defaultBanner, }
View Source
var SignalReload syscall.Signal = 0xa
SignalReload 重新加载系统信号 kill -10 pid
View Source
var Version string = "unknown"
Functions ¶
func SetProcess ¶
func SetProcess(f func() bool)
func WaitForSystemExit ¶
func WaitForSystemExit()
Types ¶
type Module ¶
type Module interface {
// Id 返回模块的唯一标识
Id() string
// Init 模块初始化,在应用启动时调用
// 此阶段主要进行模块的初始化工作,如配置加载、资源分配等
Init() error
// Start 模块启动,在所有模块初始化完成后调用
// 此阶段主要进行模块的业务逻辑启动,如启动服务、监听端口等
Start() error
// Close 模块关闭,在应用关闭时调用
// 此阶段主要进行模块的资源释放、连接关闭等清理工作
Close() error
}
Module 模块接口,所有需要被cosgo管理的模块都需要实现此接口
Source Files
¶
Click to show internal directories.
Click to hide internal directories.