Exemplo n.º 1
0
Arquivo: main.go Projeto: 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 {}
}
Exemplo n.º 2
0
Arquivo: db.go Projeto: 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())
}