refactor: 对齐后端样例工程规范
This commit is contained in:
25
backend/worker/internal/impl/new.go
Normal file
25
backend/worker/internal/impl/new.go
Normal file
@@ -0,0 +1,25 @@
|
||||
// Package impl 沿用 sample/server 创建 Worker 需要的基础设施实例。
|
||||
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/worker/internal/config"
|
||||
"github.com/patrickmn/go-cache"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var (
|
||||
RedisService *redis.RedisClient
|
||||
DBService *gorm.DB
|
||||
MemoryService *cache.Cache
|
||||
)
|
||||
|
||||
// NewImpl 初始化 Outbox 和 Mock 事件消费共用的数据库、缓存、Redis 与日志。
|
||||
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