Esempio n. 1
0
func syncAppAsDv(ac *as.Client, pool *redis.Pool, app string) error {
	stm := as.NewStatement(NS_PUSH, SET_DV, "id", "tp", "mt")
	stm.Addfilter(as.NewEqualFilter("app", app))
	p := as.NewQueryPolicy()
	p.RecordQueueSize = 200000
	rs, err := ac.Query(p, stm)
	if err != nil {
		fmt.Println("error happen When we sync @app:", app, " @err:", err)
		return err
	}
	latch := utee.NewThrottle(10000)
	for res := range rs.Results() {
		if res.Err != nil {
			return res.Err
		}
		bins := res.Record.Bins
		id, ok := bins["id"].(string)
		if !ok {
			//			log.Println("warn, id is empty", bins)
			continue
		}
		latch.Acquire()
		go Deq(pool, latch, id)
	}
	return nil
}