app_help

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

示例-App管理器

app管理器可以添加app(符合app接口)来进行统一启动统一停止,支持优雅重启功能

创建一个app管理器: apps.NewAppManager()

添加对应app进行管理: mgr.WithApp(app1)

app需符合 interfaces.ItfApp 接口

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DebugConsoleLog

func DebugConsoleLog() v1log.ILog

DebugConsoleLog 提供一个基于控制台输出的debug级别的日志记录器

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

func (s *ApiServer) Engine() *gin.Engine

func (*ApiServer) InitRouterForServer

func (s *ApiServer) InitRouterForServer(a ...interfaces.ItfGinApiServer)

InitRouterForServer 注册路由

func (*ApiServer) Name

func (s *ApiServer) Name() string

func (*ApiServer) Server

func (s *ApiServer) Server() *http.Server

func (*ApiServer) Start

func (s *ApiServer) Start() error

func (*ApiServer) Stop

func (s *ApiServer) Stop() error

func (*ApiServer) WithCors

func (s *ApiServer) WithCors(configs ...cors.Config)

WithCors 设置跨域

func (*ApiServer) WithName

func (s *ApiServer) WithName(name string)

type App

type App struct {
	SupportInitialize
	SupportServer
	SupportModule
	// contains filtered or unexported fields
}

func NewApp

func NewApp(di *dig.Container, name string) *App

func (*App) DIC

func (app *App) DIC() *dig.Container

func (*App) Name

func (app *App) Name() string

func (*App) Start

func (app *App) Start() error

func (*App) WithName

func (app *App) WithName(name string) *App

type AppManager

type AppManager struct {
	// contains filtered or unexported fields
}

func NewAppManager

func NewAppManager(logger v1log.ILog) *AppManager

NewAppManager 创建app管理器

func (*AppManager) Start

func (mgr *AppManager) Start() error

Start 启动,启动所有管理app,会阻塞直到有退出问题

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 FuncApp struct {
	Name string `json:"name"`
	Fn   func(ctx context.Context)
	// contains filtered or unexported fields
}

func (*FuncApp) Start

func (app *FuncApp) Start() error

func (*FuncApp) Stop

func (app *FuncApp) Stop() error

type SupportInitialize

type SupportInitialize struct {
	// contains filtered or unexported fields
}

SupportInitialize 初始化支持组件

用于设置初始化函数和执行初始化函数

func (*SupportInitialize) Initialize

func (app *SupportInitialize) Initialize()

Initialize 初始化

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 设置模块启动

func (*SupportModule) WithModule

func (app *SupportModule) WithModule(t bool)

WithModule 设置是否模块

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

func (app *SupportServer) Start()

Start 启动

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

Jump to

Keyboard shortcuts

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