/
application.go
51 lines (40 loc) · 1.95 KB
/
application.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package lkit_go
import (
"github.com/xlkness/lkit-go/internal/application"
)
type Scheduler = application.Scheduler
type SchedulerOption = application.SchedulerOption
// ApplicationDescInfo 调度器创建app依赖的描述信息
type ApplicationDescInfo = application.ApplicationDescInfo
type Application = application.Application
type AppOption = application.AppOption
// CommBootFlag 调度器的全局通用启动参数
type CommBootFlag = application.CommBootFlag
func NewApplicationDescInfo(name string, initFunc func(globalBootFlag *CommBootFlag, globalBootFile interface{}, app *Application) error, options ...AppOption) *ApplicationDescInfo {
adi := application.NewApplicationDescInfo(name, initFunc)
adi.WithOptions(options...)
return adi
}
// NewScheduler 创建调度器,调度器可以创建多个app和运行app
func NewScheduler(options ...SchedulerOption) *Scheduler {
return application.NewScheduler(options...)
}
// WithAppBootFlag app注入一个启动参数结构体
func WithAppBootFlag(flag interface{}) AppOption {
return application.WithAppBootFlag(flag)
}
// WithSchedulerBootConfigFileContent 设置启动配置文件的解析结构,指针结构体类型,不设置默认无起服配置,默认以yaml解析
func WithSchedulerBootConfigFileContent(content interface{}) SchedulerOption {
return application.WithSchedulerBootConfigFileContent(content)
}
// WithSchedulerBootConfigFileParser 设置起服文件解析函数,默认yaml格式
func WithSchedulerBootConfigFileParser(f func(content []byte, out interface{}) error) SchedulerOption {
return application.WithSchedulerBootConfigFileParser(f)
}
func WithSchedulerLogFileLevel(level LogLevel) SchedulerOption {
return application.WithSchedulerLogFileLevel(level)
}
// WithSchedulerCreateOneAppOption 通过scheduler创建一个app
func WithSchedulerCreateOneAppOption(appDescInfo *ApplicationDescInfo) SchedulerOption {
return application.WithSchedulerCreateOneAppOption(appDescInfo)
}