Example #1
0
// MongodbStart start connecting to mongodb
func MongodbStart() {
	fmt.Println("starting mongodb..")

	mongodbCluster := make(chan string)
	go GetMongodbCluster(mongodbCluster)

	host := <-mongodbCluster
	connectionStr := fmt.Sprintf("mongodb://%v/?maxPoolSize=10", host)
	utils.Info(fmt.Sprintf("%s", connectionStr))
	utils.Info(fmt.Sprintf("debug--------"))

	session, err := mongodb.Dial(connectionStr)
	if err != nil {
		// fmt.Println(err)
		panic(err)
	}
	fmt.Println("connected to mongodb...")
	MongodbSession = session
	// MongodbSession.SetMode(mongodb.Eventual, true)
}
Example #2
0
// Start main start cleaner
func Start(loopDelay int) {
	utils.Info(fmt.Sprintf("start cleaning!"))
	for t := range time.Tick(time.Duration(loopDelay) * time.Second) {
		utils.Info(fmt.Sprintf("%v", t))
	}
}
Example #3
0
func main() {
	utils.Info(fmt.Sprintf("cleaner started!"))
	go database.MongodbStart()
	dupCleaner.Start(loopDelay)
}