feat 初始化
This commit is contained in:
10
module/db.go
10
module/db.go
@@ -4,6 +4,7 @@ import (
|
||||
"git.hlsq.asia/alex/service-common/config"
|
||||
"git.hlsq.asia/alex/service-common/db/etcd"
|
||||
"git.hlsq.asia/alex/service-common/db/kafka"
|
||||
"git.hlsq.asia/alex/service-common/db/mongo"
|
||||
"git.hlsq.asia/alex/service-common/db/mysql"
|
||||
"git.hlsq.asia/alex/service-common/db/redis"
|
||||
"git.hlsq.asia/alex/service-common/log"
|
||||
@@ -41,6 +42,12 @@ func (m *DB) Init() error {
|
||||
return err
|
||||
}
|
||||
}
|
||||
// MONGO
|
||||
if m.Cfg.Mongo != nil {
|
||||
if err := mongo.Init(m.Cfg.Mongo); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -57,5 +64,8 @@ func (m *DB) Stop() error {
|
||||
if err := kafka.Close(); err != nil {
|
||||
log.Errorf("close kafka failed: %v", err)
|
||||
}
|
||||
if err := mongo.Close(); err != nil {
|
||||
log.Errorf("close mongo failed: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user