Documentation
¶
Overview ¶
示例-App管理器
app管理器可以添加app(符合app接口)来进行统一启动统一停止,支持优雅重启功能
创建一个app管理器: apps.NewAppManager()
添加对应app进行管理: mgr.WithApp(app1)
app需符合 interfaces.ItfApp 接口
Index ¶
- func DebugConsoleLog() v1log.ILog
- type ApiServer
- func (s *ApiServer) Engine() *gin.Engine
- func (s *ApiServer) InitRouterForServer(a ...interfaces.ItfGinApiServer)
- func (s *ApiServer) Name() string
- func (s *ApiServer) Server() *http.Server
- func (s *ApiServer) Start() error
- func (s *ApiServer) Stop() error
- func (s *ApiServer) WithCors(configs ...cors.Config)
- func (s *ApiServer) WithName(name string)
- type App
- type AppManager
- type FuncApp
- type SupportInitialize
- type SupportModule
- type SupportServer
- func (app *SupportServer) Servers() []interfaces.ItfServer
- func (app *SupportServer) Start()
- func (app *SupportServer) Stop() error
- func (app *SupportServer) WithApiServer(s ...interfaces.ItfApiServer)
- func (app *SupportServer) WithServer(s ...interfaces.ItfServer)
- func (app *SupportServer) WithWorker(s ...interfaces.ItfWorker)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ApiServer ¶
type ApiServer struct {
SupportModule
SupportInitialize
// contains filtered or unexported fields
}
func NewApiServer ¶
func NewApiServer(engine *gin.Engine, conf configstc.ServerConfig) *ApiServer
func (*ApiServer) InitRouterForServer ¶
func (s *ApiServer) InitRouterForServer(a ...interfaces.ItfGinApiServer)
InitRouterForServer 注册路由
type App ¶
type App struct {
SupportInitialize
SupportServer
SupportModule
// contains filtered or unexported fields
}
type AppManager ¶
type AppManager struct {
// contains filtered or unexported fields
}
func (*AppManager) Stop ¶
func (mgr *AppManager) Stop() error
func (*AppManager) WithApp ¶
func (mgr *AppManager) WithApp(app interfaces.ItfApp)
WithApp 添加需管理的app
func (*AppManager) WithSignalExit ¶
func (mgr *AppManager) WithSignalExit(signs ...os.Signal)
WithSignalExit 收到系统信号后退出所有app(优雅退出)
type FuncApp ¶
type SupportInitialize ¶
type SupportInitialize struct {
// contains filtered or unexported fields
}
SupportInitialize 初始化支持组件
用于设置初始化函数和执行初始化函数
func (*SupportInitialize) WithInitialize ¶
func (app *SupportInitialize) WithInitialize(fn ...func())
WithInitialize 设置初始化函数
type SupportModule ¶
type SupportModule struct {
// contains filtered or unexported fields
}
SupportModule 模块支持组件
用于设置是否模块启动
func (*SupportModule) Module ¶
func (app *SupportModule) Module() bool
func (*SupportModule) SetServer ¶
func (app *SupportModule) SetServer(servers ...interface{})
SetServer 设置模块启动
type SupportServer ¶
type SupportServer struct {
// contains filtered or unexported fields
}
SupportServer 服务支持组件
用于设置server和启动server
func (*SupportServer) Servers ¶
func (app *SupportServer) Servers() []interfaces.ItfServer
Servers 指定worker
func (*SupportServer) Stop ¶
func (app *SupportServer) Stop() error
func (*SupportServer) WithApiServer ¶
func (app *SupportServer) WithApiServer(s ...interfaces.ItfApiServer)
WithApiServer 指定apiServer
func (*SupportServer) WithServer ¶
func (app *SupportServer) WithServer(s ...interfaces.ItfServer)
WithServer 指定任意Server
func (*SupportServer) WithWorker ¶
func (app *SupportServer) WithWorker(s ...interfaces.ItfWorker)
WithWorker 指定worker
Click to show internal directories.
Click to hide internal directories.