예제 #1
0
파일: main.go 프로젝트: zackb/code
func main() {
	engine := xorm.Create("mysql", "xxxx:xxxxx@tcp(127.0.0.1:3306)/frequency_feedfront?charset=utf8")
	var feeds []Feed
	err := engine.Table("RssFeed").Where("stateId <> ? and feedParserTypeId is null", "3").Find(&feeds)
	if err != nil {
		fmt.Printf("Err: %v", err)
	}

	num_concurrent := 100
	urls := make(chan string, num_concurrent)
	var wg sync.WaitGroup
	for i := 0; i < num_concurrent; i++ {
		go func() {
			for url := range urls {
				PollFeed(url, 5)
				wg.Done()
			}
		}()
	}
	for _, feed := range feeds {
		wg.Add(1)
		urls <- feed.FeedUrl
	}
	wg.Wait()
	fmt.Println("Finished")

	select {}
}
예제 #2
0
파일: db.go 프로젝트: zackb/code
func G() {
	engine := xorm.Create("mysql", "root:fdsfds@/flix?charset=utf8")
	//err := engine.CreateTables(&GrabResult{})
	err := engine.Map(&GrabResult{})
	if err != nil {
		panic(err)
	}
	err = engine.CreateAll()
	if err != nil {
		panic(err)
	}
	id, err := engine.Insert(&GrabResult{Url: "foo"})
	fmt.Printf("$d - %i\n", id, err)

	res := GrabResult{}
	res.Url = "FFFFFFF"
	res.CreateDate = int(time.Now().Unix())
}