Esempio n. 1
0
func main() {

	for {
		msgs, err := pubsub.Pull(gcloud.ctx, "syncToFtp", 1)
		if err != nil {
			log.Println(err)
		}
		if len(msgs) > 0 {
			attr := msgs[0].Attributes
			storeID := attr["storeID"]
			orderID := attr["orderID"]

			if err := pubsub.Ack(gcloud.ctx, "syncToFtp", msgs[0].AckID); err != nil {
				log.Println("Ack failed.")
			}

			info, err := initSyncInfo(storeID, orderID)

			if err == nil {
				// fmt.Println("storeID: ", info.storeID)
				// fmt.Println("orderID: ", info.orderID)
				// fmt.Println("gcPrefix: ", info.gcPrefix)
				// fmt.Println("ftpRootPath: ", info.ftpRootPath)
				objects := queryStorageObjects(info)

				uploadObjects(info, objects)
			}
		}
	}
}
func ExamplePull() {
	ctx := Example_auth()

	// E.g. c.CreateSub("sub1", "topic1", time.Duration(0), "")
	msgs, err := pubsub.Pull(ctx, "sub1", 1)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("New message arrived: %v\n", msgs[0])
	if err := pubsub.Ack(ctx, "sub1", msgs[0].AckID); err != nil {
		log.Fatal(err)
	}
	log.Println("Acknowledged message")
}
func ExamplePull() {
	ctx := Example_auth()

	msgs, err := pubsub.Pull(ctx, "sub1", 1)
	if err != nil {
		log.Fatal(err)
	}
	log.Printf("New message arrived: %v\n", msgs[0])

	if err := pubsub.Ack(ctx, "sub1", msgs[0].AckID); err != nil {
		log.Fatal(err)
	}
	log.Println("Acknowledged message")

	demo := ClearBladeInfo{}

	demo.authenticateUser()
}
Esempio n. 4
0
func (s *pubSubServiceImpl) Pull(sub string, count int) ([]*pubsub.Message, error) {
	return pubsub.Pull(s.ctx, sub, count)
}