You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
866 B

package server
import (
"epur-pay/pkg/config"
"epur-pay/pkg/logger"
"epur-pay/pkg/mq"
"epur-pay/pkg/rds"
"epur-pay/pkg/redis"
"github.com/robfig/cron"
"net/http"
)
type App struct {
RunMode string
ServerName string
ServerApps []*http.Server
}
func NewApp(RunMode, ServerName string) *App {
p := &App{RunMode: RunMode, ServerName: ServerName}
config.Cf.Common.RunMode = p.RunMode
config.New(p.ServerName)
logger.New(config.Cf.Common.LogFilePath, config.Cf.Common.RunMode)
return p
}
func (p *App) LoadDB() *App {
rds.New(&config.Cf.Rds, config.Cf.Common.RunMode)
return p
}
func (p *App) LoadRedis() *App {
redis.New(&config.Cf.Redis)
return p
}
func (p *App) LoadCron() *App {
cron.New()
return p
}
func (p *App) LoadMq() *App {
mq.New()
return p
}
func (p *App) LoadCustomApp(F func()) *App {
if F != nil {
F()
}
return p
}