app

package
v0.0.0-...-9afdcff Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App 管理整个应用程序的生命周期,基于 uber fx 实现,以此解决依赖注入问题

func New

func New(opts ...Option) *App

New 创建一个新的 App 实例

func (*App) Run

func (a *App) Run()

Run 启动应用程序

func (*App) Start

func (a *App) Start(ctx context.Context) error

Start 启动应用程序但不阻塞

func (*App) Stop

func (a *App) Stop(ctx context.Context) error

Stop 停止应用程序

type Config

type Config struct {
	Name    string `mapstructure:"name"`    // app 名称
	Version string `mapstructure:"version"` // app 版本
	Commit  string `mapstructure:"commit"`  // git 提交号
	// contains filtered or unexported fields
}

type Option

type Option func(*Config)

Option 函数式配置项

func WithCommit

func WithCommit(commit string) Option

WithCommit 配置 git 提交号

func WithConfig

func WithConfig(cfg Config) Option

WithConfig 整体替换配置

func WithInvokes

func WithInvokes(invokes ...fx.Option) Option

WithInvokes 配置 fx.Invoke(初始化逻辑)

func WithModules

func WithModules(mods ...fx.Option) Option

WithModules 配置模块(模块 = fx.Option)

func WithName

func WithName(n string) Option

WithName 配置应用名称

func WithProvides

func WithProvides(provides ...fx.Option) Option

WithProvides 配置服务提供者,用于依赖注入

func WithVersion

func WithVersion(v string) Option

WithVersion 配置应用版本号

Jump to

Keyboard shortcuts

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