Exemplo n.º 1
0
func DoFetch(cf *config.Config) {
	log.Println("=== FETCH BEGIN ===")
	s := new(fetcher.Session)
	s.Config = cf
	for _, realm := range cf.RealmsList {
		for _, locale := range cf.LocalesList {
			file_url, file_ts := s.Fetch_FileURL(realm, locale)
			log.Printf("FILE URL: %s", file_url)
			log.Printf("FILE PIT: %s / %s", file_ts, util.TSStr(file_ts.UTC()))
			fname := util.Make_FName(realm, file_ts, true)
			json_fname := cf.DownloadDirectory + fname
			if !util.CheckFile(json_fname) {
				log.Printf("downloading from %s ...", file_url)
				data := s.Get(file_url)
				log.Printf("... got %d octets", len(data))
				zdata := util.Zip(data)
				log.Printf("... zipped to %d octets (%d%%)",
					len(zdata), len(zdata)*100/len(data))
				util.Store(json_fname, zdata)
				log.Printf("stored to %s .", json_fname)
			} else {
				log.Println("... already downloaded")
			}
		}
	}
	log.Println("=== FETCH END ===")
}
Exemplo n.º 2
0
func (prc *AuctionProcessor) LoadState() {
	if prc.Started {
		log.Panic("LoadState inside snapshot session")
	}
	if util.CheckFile(prc.StateFName) {
		log.Printf("AuctionProcessor loading state from %s ...", prc.StateFName)
		data, _ := util.Load(prc.StateFName)
		if err := json.Unmarshal(data, &prc.State); err != nil {
			log.Panicf("... failed: %s", prc.StateFName, err)
		}
		log.Printf("... loaded with %d list enties", len(prc.State.WorkList))
		prc.State.WorkSet = make(WorkSetType)
		for _, e := range prc.State.WorkList {
			prc.State.WorkSet[e.Entry.Auc] = e
		}
	} else {
		log.Printf("AuctionProcessor has no state named %s ...", prc.StateFName)
	}
}