application

package
v0.0.0-...-28a9172 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultStopTimeout = time.Minute

Variables

This section is empty.

Functions

This section is empty.

Types

type Application

type Application interface {
	Name() string
	// 启动程序. 程序会在收到终止信号 或 所有任务执行完毕 或 context.Done() 时终止任务.
	// 终止信号: syscall.SIGTERM, syscall.SIGINT, syscall.SIGQUIT
	Run(context.Context)
	// 添加任务
	AddBundle(...IBundle)
}

func New

func New(_opts ...Option) Application

type IBundle

type IBundle interface {
	GetName() string
	Run(context.Context)
	Stop(context.Context)
}

任务, http、rest 服务, corn job 都是任务. 一个程序由多个任务组成.

type Option

type Option func(*options)

func OptionAfterStart

func OptionAfterStart(fn func(ctx context.Context) error) Option

func OptionAfterStop

func OptionAfterStop(fn func(ctx context.Context) error) Option

func OptionBeforeStart

func OptionBeforeStart(fn func(ctx context.Context) error) Option

func OptionBeforeStop

func OptionBeforeStop(fn func(ctx context.Context) error) Option

func OptionName

func OptionName(name string) Option

func OptionSentryIncludePaths

func OptionSentryIncludePaths(paths ...string) Option

sentry path

func OptionStopTimeout

func OptionStopTimeout(timeout time.Duration) Option

收到终止信号后, 如果任务无法正常结束时强制结束的时间.

func OptionWithLogger

func OptionWithLogger(logger logger.Logger) Option

func OptionWithProfiler

func OptionWithProfiler(profilePort int) Option

启用 pprof 分析

Jump to

Keyboard shortcuts

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