Documentation ¶
Index ¶
- Constants
- func CronJobSingle() *cron.Cron
- func GlobalCtx() *simpleioc.GlobalContext
- func GormDb() *gorm.DB
- func MongoDb() *mongodb.Client
- func RedisCache() cache.Rediser
- type Application
- type ApplicationBuild
- func (app *ApplicationBuild) EnableCache(redConfig cache.RedisOptions) *ApplicationBuild
- func (app *ApplicationBuild) EnableDb(dbConfig *datasource.PostgresConfig, models ...interface{}) *ApplicationBuild
- func (app *ApplicationBuild) EnableMongoDB(dbConfig *mongodb.MongoDBConfig) *ApplicationBuild
- func (app *ApplicationBuild) EnableStaticSource(file embed.FS) *ApplicationBuild
- func (app *ApplicationBuild) EnableWeb(timeFormat, port, logLevel string, components webiris.PartyComponent) *ApplicationBuild
- func (app *ApplicationBuild) InitCronJob() *ApplicationBuild
- func (app *ApplicationBuild) InitLog(outDirPath, level string) *ApplicationBuild
- func (app *ApplicationBuild) LoadConfig(configStruct interface{}, loaderFun func(loadconf.Loader)) error
- func (app *ApplicationBuild) SetSeeds(seedFuncs ...seed.SeedFunc) *ApplicationBuild
- func (app *ApplicationBuild) SetupToken(AMinute, RHour time.Duration, TokenIssuer string) *ApplicationBuild
- type ApplicationBuilder
Constants ¶
View Source
const AfterSecond = time.Second * 2
AfterSecond 默认时长后开始执行 后置函数
View Source
const (
// TimeFormat 日期格式
TimeFormat = "2006-01-02 15:04:05"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Application ¶
type Application interface { // Start 用于读取配置文件、启动所有服务 Start(builder func(ctx context.Context, builder *ApplicationBuild) error) error }
Application app启动器接口
type ApplicationBuild ¶
type ApplicationBuild struct { //=========================================》 启动标识 // 是否启动定时服务,在enableCronjob后为true,会自动start(),即开始调用定时Cron表达式函数 IsRunningCronJob bool // 静态服务文件系统 StaticFs http.FileSystem // 是否开启web IsEnableWeb bool // 是否开启数据库 IsEnableDB bool // 是否开启redis IsEnableCache bool // 是否开始RabbitMq IsEnableRabbitMq bool // 是否开始定时任务 IsEnableCronTask bool // 是否开启mongoDB IsEnableMongoDB bool // 是否开启静态服务文件 IsEnableStaticFileServe bool // 是否开启日志zapLogs IsEnableZapLogs bool // contains filtered or unexported fields }
func (*ApplicationBuild) EnableCache ¶
func (app *ApplicationBuild) EnableCache(redConfig cache.RedisOptions) *ApplicationBuild
EnableCache 启动缓存
func (*ApplicationBuild) EnableDb ¶
func (app *ApplicationBuild) EnableDb(dbConfig *datasource.PostgresConfig, models ...interface{}) *ApplicationBuild
EnableDb 启动数据库操作对象
func (*ApplicationBuild) EnableMongoDB ¶ added in v1.0.7
func (app *ApplicationBuild) EnableMongoDB(dbConfig *mongodb.MongoDBConfig) *ApplicationBuild
EnableMongoDB 启动MongoDB客户端
func (*ApplicationBuild) EnableStaticSource ¶ added in v1.1.1
func (app *ApplicationBuild) EnableStaticSource(file embed.FS) *ApplicationBuild
EnableStaticSource 加载web服务静态资源文件
func (*ApplicationBuild) EnableWeb ¶
func (app *ApplicationBuild) EnableWeb(timeFormat, port, logLevel string, components webiris.PartyComponent) *ApplicationBuild
EnableWeb 启动Web服务
func (*ApplicationBuild) InitCronJob ¶ added in v1.0.7
func (app *ApplicationBuild) InitCronJob() *ApplicationBuild
InitCronJob 初始化定时任务对象,存放入IOC
func (*ApplicationBuild) InitLog ¶ added in v1.0.7
func (app *ApplicationBuild) InitLog(outDirPath, level string) *ApplicationBuild
InitLog 初始化自定义日志
func (*ApplicationBuild) LoadConfig ¶
func (app *ApplicationBuild) LoadConfig(configStruct interface{}, loaderFun func(loadconf.Loader)) error
LoadConfig 加载配置文件、环境变量值
func (*ApplicationBuild) SetSeeds ¶ added in v1.0.7
func (app *ApplicationBuild) SetSeeds(seedFuncs ...seed.SeedFunc) *ApplicationBuild
SetSeeds 设置启动项目时,要执行的一些钩子函数
func (*ApplicationBuild) SetupToken ¶ added in v1.0.8
func (app *ApplicationBuild) SetupToken(AMinute, RHour time.Duration, TokenIssuer string) *ApplicationBuild
SetupToken 设置系统token有效期
type ApplicationBuilder ¶
type ApplicationBuilder interface { EnableWeb(timeFormat, port, logLevel string, components webiris.PartyComponent) *ApplicationBuild // 启动web服务 EnableDb(dbConfig *datasource.PostgresConfig, models ...interface{}) *ApplicationBuild // 启动数据库 EnableCache(redConfig cache.RedisOptions) *ApplicationBuild // 启动缓存 LoadConfig(configStruct interface{}, loaderFun func(loadconf.Loader)) error // 加载配置文件、环境变量等 InitLog(outDirPath, level string) *ApplicationBuild // 初始化日志打印 EnableMongoDB(dbConfig *mongodb.MongoDBConfig) *ApplicationBuild // 启动缓存数据库 InitCronJob() *ApplicationBuild // 初始化定时任务 SetupToken(AMinute, RHour time.Duration, TokenIssuer string) *ApplicationBuild // 配置wen-token属性 EnableStaticSource(file embed.FS) *ApplicationBuild // 加载静态资源 }
ApplicationBuilder app builder接口提供系统初始化服务基础功能
Click to show internal directories.
Click to hide internal directories.