Esempio n. 1
0
func NewTaobaoESStore(c Config) *TaobaoESStore {
	var esstor = &TaobaoESStore{}
	var err error
	var m = mongodb.MongodbConf{}

	esstor.client, err = elastic.NewClient(elastic.SetURL(strings.Split(c.ESHost, ",")...))
	if err != nil {
		log.Fatal(err)
	}

	m.Db = "xu_precise"
	m.Host = c.MgoStoreHost
	m.Port = c.MgoStorePort
	m.UName = c.mgoStoreUname
	m.Upwd = c.mgoStoreUpwd
	esstor.store, err = mongodb.NewMongodb(m)
	if err != nil {
		log.Fatal(err)
	}
	esstor.prefix = c.TablePrefixe
	esstor.initCategory()
	esstor.geohost = c.GeoHost
	esstor.bulk = esstor.client.Bulk()
	return esstor
}
Esempio n. 2
0
File: fun.go Progetto: qgweb/new
// 获取mongo对象
func GetMongoObj() (*mongodb.Mongodb, error) {
	murls := strings.Split(GetConfVal("zhejiang::mongo_url"), ":")
	conf := mongodb.MongodbConf{}
	conf.Host = murls[0]
	conf.Port = murls[1]
	conf.Db = "data_source"
	return mongodb.NewMongodb(conf)
}
Esempio n. 3
0
File: fun.go Progetto: qgweb/new
// 获取mongodb对象
func GetMongoObj(iniPath string, section string) (*mongodb.Mongodb, error) {
	confObj, err := GetConfObj(iniPath)
	if err != nil {
		return nil, errors.Trace(err)
	}
	conf := mongodb.MongodbConf{}
	conf.Host = confObj.String(section + "::" + "host")
	conf.Db = confObj.String(section + "::" + "db")
	conf.Port = confObj.String(section + "::" + "port")
	conf.UName = confObj.String(section + "::" + "user")
	conf.Upwd = confObj.String(section + "::" + "pwd")
	return mongodb.NewMongodb(conf)
}
Esempio n. 4
0
File: ad-geo.go Progetto: qgweb/new
func init() {
	var cf mongodb.MongodbConf
	var err error
	cf.Db = fp.mongoDb
	cf.Host = fp.mongoHost
	cf.Port = fp.mongoPort
	cf.UName = fp.mongoUname
	cf.Upwd = fp.mongoUpwd
	db, err = mongodb.NewMongodb(cf)
	if err != nil {
		log.Fatal(err)
	}
}