fusenapi/server/info/internal/svc/servicecontext.go

33 lines
658 B
Go
Raw Normal View History

2023-08-31 08:17:32 +00:00
package svc
import (
"fusenapi/server/info/internal/config"
"fusenapi/shared"
"fusenapi/initalize"
"fusenapi/model/gmodel"
"gorm.io/gorm"
)
type ServiceContext struct {
Config config.Config
SharedState *shared.SharedState
MysqlConn *gorm.DB
AllModels *gmodel.AllModelsGen
RabbitMq *initalize.RabbitMqHandle
}
func NewServiceContext(c config.Config) *ServiceContext {
conn := initalize.InitMysql(c.SourceMysql)
return &ServiceContext{
Config: c,
MysqlConn: conn,
SharedState: nil,
AllModels: gmodel.NewAllModels(initalize.InitMysql(c.SourceMysql)),
RabbitMq: initalize.InitRabbitMq(c.SourceRabbitMq, nil),
}
}