本文整理匯總了Golang中github.com/pendo-io/appwrap.Datastore.NewKey方法的典型用法代碼示例。如果您正苦於以下問題:Golang Datastore.NewKey方法的具體用法?Golang Datastore.NewKey怎麽用?Golang Datastore.NewKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pendo-io/appwrap.Datastore
的用法示例。
在下文中一共展示了Datastore.NewKey方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: RemoveJob
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
}
示例2: makeTaskKeys
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
}
示例3: createJob
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)
}
示例4: GetJob
func GetJob(ds appwrap.Datastore, jobId int64) (JobInfo, error) {
return getJob(ds, ds.NewKey(JobEntity, "", jobId, nil))
}