示例#1
0
// syncTaskJob would do whatever syncing is necessary in the background
func syncTaskJob(j *que.Job) error {
	var synctask sync.SyncTask
	err := json.Unmarshal(j.Args, &synctask)
	if err != nil {
		log.WithField("args", string(j.Args)).Error("Unable to unmarshal job arguments into SyncTask")
		return err
	}

	log.WithField("SyncTask", synctask).Info("Processing Synctask!")

	stvClientImpl := stv.CreateStravaClient(synctask.StravaToken)
	rkClientImpl := rk.CreateRKClient(synctask.RunkeeperToken)
	_, _, err = synctask.Sync(stvClientImpl, rkClientImpl)
	if err != nil {
		log.WithField("args", string(j.Args)).WithField("QueId", j.ID).Error("Error while syncing synctask.")
		return err
	}

	j.Delete()
	j.Done()

	return nil
}