refactor: 对齐后端样例工程规范
This commit is contained in:
25
backend/api/internal/impl/new.go
Normal file
25
backend/api/internal/impl/new.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Package impl 统一创建数据库、Redis、内存缓存与日志基础设施。
|
||||
package impl
|
||||
|
||||
import (
|
||||
"git.apinb.com/bsm-sdk/core/cache/redis"
|
||||
"git.apinb.com/bsm-sdk/core/logger"
|
||||
"git.apinb.com/bsm-sdk/core/with"
|
||||
"git.apinb.com/heqiapp/platforms/backend/api/internal/config"
|
||||
"github.com/patrickmn/go-cache"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
RedisService *redis.RedisClient
|
||||
DBService *gorm.DB
|
||||
MemoryService *cache.Cache
|
||||
)
|
||||
|
||||
// NewImpl 与 sample/server 保持一致,所有进程通过此处创建共享基础设施。
|
||||
func NewImpl() {
|
||||
MemoryService = with.Memory(nil)
|
||||
RedisService = with.RedisCache(config.Spec.Cache)
|
||||
DBService = with.Databases(config.Spec.Databases, nil)
|
||||
logger.New(nil)
|
||||
}
|
||||
Reference in New Issue
Block a user