func RemoveJob(ds appwrap.Datastore, jobId int64) error { jobKey := ds.NewKey(JobEntity, "", jobId, nil) q := ds.NewQuery(TaskEntity).Filter("Job =", jobKey).KeysOnly() keys, err := q.GetAll(nil) if err != nil { return err } keys = append(keys, jobKey) i := 0 for i < len(keys) { last := i + 250 if last > len(keys) { last = len(keys) } if err := ds.DeleteMulti(keys[i:last]); err != nil { return err } i = last } return nil }
func makeTaskKeys(ds appwrap.Datastore, firstId int64, count int) []*datastore.Key { taskKeys := make([]*datastore.Key, count) for i := 0; i < count; i++ { taskKeys[i] = ds.NewKey(TaskEntity, "", firstId+int64(i), nil) } return taskKeys }
func createJob(ds appwrap.Datastore, urlPrefix string, writerNames []string, onCompleteUrl string, separateReduceItems bool, jsonParameters string, retryCount int) (*datastore.Key, error) { if retryCount == 0 { // default retryCount = 3 } key := ds.NewKey(JobEntity, "", 0, nil) job := JobInfo{ UrlPrefix: urlPrefix, Stage: StageFormation, UpdatedAt: time.Now(), StartTime: time.Now(), OnCompleteUrl: onCompleteUrl, SeparateReduceItems: separateReduceItems, WriterNames: writerNames, RetryCount: retryCount, JsonParameters: jsonParameters, } return ds.Put(key, &job) }
func GetJob(ds appwrap.Datastore, jobId int64) (JobInfo, error) { return getJob(ds, ds.NewKey(JobEntity, "", jobId, nil)) }