tianxiaoliang commented on a change in pull request #155:
URL: https://github.com/apache/servicecomb-kie/pull/155#discussion_r477125816
##########
File path: server/service/mongo/session/session.go
##########
@@ -191,23 +198,19 @@ func GetColInfo(ctx context.Context, name string)
(*CollectionInfo, error) {
return nil, ErrGetPipeline
}
-//InitMongodb get collection info
-func InitMongodb() {
+//InitDB build mongo db schema
+func InitDB() {
session, err := mgo.Dial(config.GetDB().URI)
if err != nil {
- panic(err)
+ openlogging.Fatal("can not dial db:" + err.Error())
}
defer session.Close()
session.SetMode(mgo.Monotonic, true)
- //counter
- c := session.DB(DBName).C(CollectionCounter)
- docs := map[string]interface{}{"name": "revision_counter", "count": 1,
"domain": "default"}
- err = c.Insert(docs)
- if err != nil {
- panic(err)
- }
+
+ ensureRevisionCounter(session)
+
//kv
- c = session.DB(DBName).C("kv")
+ c := session.DB(DBName).C("kv")
err = c.Create(&mgo.CollectionInfo{Validator: bson.M{
Review comment:
这个老代码err未处理,真的出错抓不到
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]