cosgo

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2024 License: Apache-2.0 Imports: 19 Imported by: 7

README

cosgo

go game 开发中

Documentation

Index

Constants

View Source
const (
	AppDir                      string = "dir" //工作目录
	AppName                     string = "name"
	AppPprof                    string = "pprof"
	AppDebug                    string = "debug"
	AppConfigNamePidFile        string = "pid"           //pid file dir
	AppConfigNameLogsPath       string = "logs.path"     //logs dir
	AppConfigNameLogsLevel      string = "logs.level"    //logs level
	AppConfigNameDaemonize      string = "daemonize"     //后台运行
	AppConfigNameConfigFileExt  string = "ConfigFileExt" //config file default ext name,只能在程序中设置
	AppConfigNameConfigFileName string = "config"        //config 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 = 10

SignalReload 重新加载系统信号 kill -10 pid

View Source
var Version string = "unknown"

Functions

func Abs

func Abs(dir ...string) string

Abs 获取以工作路径为起点的绝对路径

func Close

func Close(force bool)

Close 外部关闭程序

func Debug

func Debug() bool

func Dir

func Dir() string

Dir 程序工作目录

func Name

func Name() string

Name 项目内部获取appName

func On

func On(e EventType, f EventFunc)

func Range added in v0.0.5

func Range(f func(IModule) bool)

func Reload added in v0.0.2

func Reload()

func SIGHUP added in v0.0.2

func SIGHUP()

SIGHUP 关闭控制台

func SetBanner

func SetBanner(f func())

SetBanner 设置默认启动界面,启动完所有MOD后执行

func SetProcess

func SetProcess(f func() bool)

func Start

func Start(waitForSystemExit bool, mods ...IModule)

*

  • 应用程序启动
  • @param mods 需注册的模块

func Use

func Use(mods ...IModule)

func WaitForSystemExit

func WaitForSystemExit()

Types

type EventFunc

type EventFunc func() error

type EventType

type EventType int32
const (
	EventTypStart   EventType = iota //开始启动
	EventTypLoader                   //(Init)加载完成
	EventTypReady                    //启动完成
	EventTypClosing                  //开始关闭
	EventTypStopped                  //停止之后
)

type IModule added in v0.0.2

type IModule interface {
	ID() string
	Init() error
	Start() error
	Close() error
	Reload() error
}

type Module

type Module struct {
	Id string
}

func NewModule

func NewModule(id string) *Module

func (*Module) Close

func (m *Module) Close() error

func (*Module) ID

func (m *Module) ID() string

func (*Module) Init

func (m *Module) Init() error

func (*Module) Reload added in v0.0.2

func (m *Module) Reload() error

func (*Module) Start

func (m *Module) Start() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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