You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
cronsun/models/common.go

38 lines
484 B

package models
import (
"sunteng/commons/db/imgo"
"sunteng/cronsun/conf"
)
var (
initialized bool
)
func Init() (err error) {
if initialized {
return
}
// init id creator
if err = initID(); err != nil {
return
}
// init config
if err = conf.Init(); err != nil {
return
}
// init etcd client
if DefalutClient, err = NewClient(conf.Config); err != nil {
return
}
// init mongoDB
mgoDB = imgo.NewMdbWithConf(conf.Config.Mgo)
initialized = true
return
}