Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: impl/prod/raw_datastore.go

Issue 1357343002: Add missing AllocateIDs API. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package prod 5 package prod
6 6
7 import ( 7 import (
8 ds "github.com/luci/gae/service/datastore" 8 ds "github.com/luci/gae/service/datastore"
9 "github.com/luci/gae/service/info" 9 "github.com/luci/gae/service/info"
10 "github.com/luci/luci-go/common/errors" 10 "github.com/luci/luci-go/common/errors"
(...skipping 28 matching lines...) Expand all
39 me, ok := err.(errors.MultiError) 39 me, ok := err.(errors.MultiError)
40 if ok { 40 if ok {
41 for i, err := range me { 41 for i, err := range me {
42 cb(i, err) 42 cb(i, err)
43 } 43 }
44 return nil 44 return nil
45 } 45 }
46 return err 46 return err
47 } 47 }
48 48
49 func (d rdsImpl) AllocateIDs(incomplete *ds.Key, n int) (start int64, err error) {
50 par, err := dsF2R(d, incomplete.Parent())
51 if err != nil {
52 return
53 }
54
55 start, _, err = datastore.AllocateIDs(d, incomplete.Last().Kind, par, n)
dnj (Google) 2015/09/22 06:36:06 (nit/thought): incomplete.Last().Kind() should pro
iannucci 2015/09/22 16:41:05 Yeah... at the time I thought it was a good idea..
56 return
57 }
58
49 func (d rdsImpl) DeleteMulti(ks []*ds.Key, cb ds.DeleteMultiCB) error { 59 func (d rdsImpl) DeleteMulti(ks []*ds.Key, cb ds.DeleteMultiCB) error {
50 keys, err := dsMF2R(d, ks) 60 keys, err := dsMF2R(d, ks)
51 if err == nil { 61 if err == nil {
52 err = datastore.DeleteMulti(d, keys) 62 err = datastore.DeleteMulti(d, keys)
53 } 63 }
54 return idxCallbacker(err, len(ks), func(_ int, err error) { 64 return idxCallbacker(err, len(ks), func(_ int, err error) {
55 cb(err) 65 cb(err)
56 }) 66 })
57 } 67 }
58 68
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 208 }
199 209
200 func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.Tran sactionOptions) error { 210 func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *ds.Tran sactionOptions) error {
201 ropts := (*datastore.TransactionOptions)(opts) 211 ropts := (*datastore.TransactionOptions)(opts)
202 return datastore.RunInTransaction(d, f, ropts) 212 return datastore.RunInTransaction(d, f, ropts)
203 } 213 }
204 214
205 func (d rdsImpl) Testable() ds.Testable { 215 func (d rdsImpl) Testable() ds.Testable {
206 return nil 216 return nil
207 } 217 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698