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

Unified Diff: service/datastore/pls.go

Issue 1427933002: Decouple PLS from MGS. (Closed) Base URL: https://github.com/luci/gae@master
Patch Set: Add test for MGS that fails to export $kind. Created 5 years, 2 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/pls.go
diff --git a/service/datastore/pls.go b/service/datastore/pls.go
index e3bb3194fb8a8d57a85f045c4c125a02c9d21306..a323112f3b01602ea81cecbb0f65418765b29745 100644
--- a/service/datastore/pls.go
+++ b/service/datastore/pls.go
@@ -93,7 +93,10 @@ import (
// methods. So if your GetMeta handles "kind", but you explicitly have a
// $kind field, the $kind field will take precedence and your GetMeta
// implementation will not be called for "kind".
-func GetPLS(obj interface{}) PropertyLoadSaver {
+func GetPLS(obj interface{}) interface {
+ PropertyLoadSaver
+ MetaGetterSetter
+} {
v := reflect.ValueOf(obj)
if v.Kind() != reflect.Ptr || v.Elem().Kind() != reflect.Struct {
return &structPLS{c: &structCodec{problem: ErrInvalidEntityType}}
@@ -106,6 +109,13 @@ func GetPLS(obj interface{}) PropertyLoadSaver {
return &structPLS{v, c}
}
+func getMGS(obj interface{}) MetaGetterSetter {
+ if mgs, ok := obj.(MetaGetterSetter); ok {
+ return mgs
+ }
+ return GetPLS(obj)
+}
+
func getCodec(structType reflect.Type) *structCodec {
structCodecsMutex.RLock()
c, ok := structCodecs[structType]

Powered by Google App Engine
This is Rietveld 408576698