Пример #1
0
func main() {
	flag.Parse()
	var sub pubsub.PubSubscriber
	if *provider == "google" {
		sub = pubsub.NewGooglePubSubscriber()
	} else {
		sub = pubsub.NewSuperFeedrPubSubscriber(*verify_mode, "Hearts", "Refresh")
	}
	switch *method {
	case "subscribe":
		code, err := sub.Subscribe(*uri)
		fmt.Println(code, err)
	case "unsubscribe":
		code, err := sub.Unsubscribe(*uri)
		fmt.Println(code, err)
	case "retrieve":
		s, err := sub.Retrieve(*uri, 1)
		fmt.Println(s, err)
	}
}
Пример #2
0
func update_work() {
	backend_context.Lock()
	defer backend_context.Unlock()
	w := atomic.AddInt64(&backend_context.working, 1)
	defer atomic.AddInt64(&backend_context.working, -1)
	if w != 1 {
		return
	}
	fss, err := feedsource_expired(time.Now().Unix())
	if err != nil || len(fss) == 0 {
		return
	}
	idx := rand.Intn(len(fss))
	fs := fss[idx]
	newfs, fes, err := feed_fetch(fs.Uri)
	newfs.Type = fs.Type
	newfs.EnableProxy = fs.EnableProxy
	newfs.Categories = append(newfs.Categories, fs.Categories...)
	if newfs.Logo == "" {
		newfs.Logo = fs.Logo
	}

	newfs.SubscribeState = fs.SubscribeState
	newfs.LastTouch = int64(unixtime.TimeNow())
	newfs.LastUpdate = newfs.LastTouch
	newfs.NextTouch = newfs.Period + newfs.LastTouch
	err = feedsource_save(newfs)
	fes = readentry_filter(fes)
	backend_push_update(newfs, fes, err)
	ps := pubsub.NewSuperFeedrPubSubscriber("async", "Hearts", "Refresh")
	sc, err := ps.Subscribe(fs.Uri)
	if err != nil {
		log.Println("pubsub-google", sc, err)
	}
	ps = pubsub.NewGooglePubSubscriber()
	sc, err = ps.Subscribe(fs.Uri)
	log.Println("update-tick", fs.Name, sc, err)
}