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

Unified Diff: service/datastore/multiarg.go

Issue 2007123002: datastore: Update AllocateIDs to take keys. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Add empty arg/key short-circuits for other varidic methods. 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/multiarg.go
diff --git a/service/datastore/multiarg.go b/service/datastore/multiarg.go
index 9250acec811a89efd4e626a7f4aeef5b8eb9e278..9661e6255f2faa43517cbcdf4e72d2ccea961d54 100644
--- a/service/datastore/multiarg.go
+++ b/service/datastore/multiarg.go
@@ -16,7 +16,7 @@ type multiArgType struct {
getPM func(slot reflect.Value) (PropertyMap, error)
getMetaPM func(slot reflect.Value) PropertyMap
setPM func(slot reflect.Value, pm PropertyMap) error
- setKey func(slot reflect.Value, k *Key)
+ setKey func(slot reflect.Value, k *Key) bool
newElem func() reflect.Value
}
@@ -97,8 +97,8 @@ func multiArgTypePLS(et reflect.Type) *multiArgType {
setPM: func(slot reflect.Value, pm PropertyMap) error {
return slot.Interface().(PropertyLoadSaver).Load(pm)
},
- setKey: func(slot reflect.Value, k *Key) {
- PopulateKey(slot.Interface(), k)
+ setKey: func(slot reflect.Value, k *Key) bool {
+ return PopulateKey(slot.Interface(), k)
},
}
switch et.Kind() {
@@ -155,8 +155,8 @@ func multiArgTypePLSPtr(et reflect.Type) *multiArgType {
setPM: func(slot reflect.Value, pm PropertyMap) error {
return slot.Addr().Interface().(PropertyLoadSaver).Load(pm)
},
- setKey: func(slot reflect.Value, k *Key) {
- PopulateKey(slot.Addr().Interface(), k)
+ setKey: func(slot reflect.Value, k *Key) bool {
+ return PopulateKey(slot.Addr().Interface(), k)
},
newElem: func() reflect.Value {
return reflect.New(et).Elem()
@@ -183,8 +183,8 @@ func multiArgTypeStruct(et reflect.Type) *multiArgType {
setPM: func(slot reflect.Value, pm PropertyMap) error {
return toPLS(slot).Load(pm)
},
- setKey: func(slot reflect.Value, k *Key) {
- PopulateKey(toPLS(slot), k)
+ setKey: func(slot reflect.Value, k *Key) bool {
+ return PopulateKey(toPLS(slot), k)
},
newElem: func() reflect.Value {
return reflect.New(et).Elem()
@@ -211,8 +211,8 @@ func multiArgTypeStructPtr(et reflect.Type) *multiArgType {
setPM: func(slot reflect.Value, pm PropertyMap) error {
return toPLS(slot).Load(pm)
},
- setKey: func(slot reflect.Value, k *Key) {
- PopulateKey(toPLS(slot), k)
+ setKey: func(slot reflect.Value, k *Key) bool {
+ return PopulateKey(toPLS(slot), k)
},
newElem: func() reflect.Value {
return reflect.New(et.Elem())
@@ -235,8 +235,8 @@ func multiArgTypeInterface() *multiArgType {
setPM: func(slot reflect.Value, pm PropertyMap) error {
return mkPLS(slot.Elem().Interface()).Load(pm)
},
- setKey: func(slot reflect.Value, k *Key) {
- PopulateKey(slot.Elem().Interface(), k)
+ setKey: func(slot reflect.Value, k *Key) bool {
+ return PopulateKey(slot.Elem().Interface(), k)
},
}
}
@@ -249,6 +249,10 @@ func multiArgTypeKeyExtraction() *multiArgType {
getKey: func(aid, ns string, slot reflect.Value) (*Key, error) {
return slot.Interface().(*Key), nil
},
+ setKey: func(slot reflect.Value, k *Key) bool {
+ slot.Elem().Set(reflect.ValueOf(k).Elem())
+ return true
+ },
}
}

Powered by Google App Engine
This is Rietveld 408576698