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

Unified Diff: service/datastore/interface.go

Issue 2007123002: datastore: Update AllocateIDs to take keys. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: service/datastore/interface.go
diff --git a/service/datastore/interface.go b/service/datastore/interface.go
index c70dd53c54095804b6f88826e452f27f4707a14a..701a0df556caadcfea4b8635aa5d9a46b732e059 100644
--- a/service/datastore/interface.go
+++ b/service/datastore/interface.go
@@ -45,12 +45,14 @@ func (bl BoolList) Any() bool {
// using this package's GetPLS function.
type Interface interface {
// AllocateIDs allows you to allocate IDs from the datastore without putting
- // any data. `incomplete` must be a PartialValid Key. If there's no error,
- // a contiguous block of IDs of n length starting at `start` will be reserved
- // indefinitely for the user application code for use in new keys. The
- // appengine automatic ID generator will never automatically assign these IDs
- // for Keys of this type.
- AllocateIDs(incomplete *Key, n int) (start int64, err error)
+ // any data. The supplied keys must be PartialValid and share the same entity
+ // type.
+ //
+ // If there's no error, a new slice of complete keys will be returned with
+ // reserved integer IDs // assigned to them. The appengine automatic ID
+ // generator will never automatically assign these IDs to any other Keys of
+ // this type.
+ AllocateIDs(keys ...*Key) ([]*Key, error)
// KeyForObj extracts a key from src.
//
@@ -77,6 +79,10 @@ type Interface interface {
// specified parameters.
NewKey(kind, stringID string, intID int64, parent *Key) *Key
+ // NewIncompleteKeys allocates count incomplete keys sharing the same kind and
+ // parent. It is useful as input to AllocateIDs.
+ NewIncompleteKeys(count int, kind string, parent *Key) []*Key
+
// NewKeyToks constructs a new key in the current appID/Namespace, using the
// specified key tokens.
NewKeyToks([]KeyTok) *Key

Powered by Google App Engine
This is Rietveld 408576698