43 lines
1.0 KiB
Go
43 lines
1.0 KiB
Go
package impl
|
|
|
|
import (
|
|
"git.apinb.com/bsm-sdk/core/cache/redis"
|
|
"git.apinb.com/bsm-sdk/core/logger"
|
|
"git.apinb.com/bsm-sdk/core/types"
|
|
"git.apinb.com/bsm-sdk/core/vars"
|
|
"git.apinb.com/bsm-sdk/core/with"
|
|
"git.apinb.com/ops/files/internal/config"
|
|
"git.apinb.com/ops/files/internal/storage"
|
|
clientv3 "go.etcd.io/etcd/client/v3"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
var (
|
|
RedisService *redis.RedisClient
|
|
EtcdService *clientv3.Client
|
|
DBService *gorm.DB
|
|
StorageService *storage.Client
|
|
Logger *logger.Logger
|
|
)
|
|
|
|
// NewImpl 初始化各类服务实例。
|
|
func NewImpl() {
|
|
DBService = with.Databases(config.Spec.Databases, &types.SqlOptions{
|
|
MaxIdleConns: vars.SqlOptionMaxIdleConns,
|
|
MaxOpenConns: vars.SqlOptionMaxOpenConns,
|
|
ConnMaxLifetime: vars.SqlOptionConnMaxLifetime,
|
|
LogStdout: false,
|
|
Debug: false,
|
|
})
|
|
|
|
var err error
|
|
StorageService, err = storage.New(config.Spec.ObjectStorage)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
RedisService = with.RedisCache(config.Spec.Cache)
|
|
EtcdService = with.Etcd(config.Spec.Etcd)
|
|
logger.New(nil)
|
|
}
|