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

Unified Diff: service/datastore/properties.go

Issue 1401533007: Add ability to override just the metadata in a struct. (Closed) Base URL: https://github.com/luci/gae.git@add_exists_method
Patch Set: 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/properties.go
diff --git a/service/datastore/properties.go b/service/datastore/properties.go
index 60d8b423ad6dfc4fe7399a0570df4e7fbba883d8..9746c67b1d8e4d920023ef0528570bf79c821073 100644
--- a/service/datastore/properties.go
+++ b/service/datastore/properties.go
@@ -680,20 +680,36 @@ type PropertyLoadSaver interface {
// which was held by this PropertyLoadSaver.
Save(withMeta bool) (PropertyMap, error)
+ MetaGetterSetter
+
+ // Problem indicates that this PLS has a fatal problem. Usually this is
+ // set when the underlying struct has recursion, invalid field types, nested
+ // slices, etc.
+ Problem() error
+}
+
+// MetaGetterSetter is the subset of PropertyLoadSaver which pertains to
+// getting and saving metadata.
+//
+// A *struct may implement this interface to provide metadata which is
+// supplimental to the variety described by GetPLS. For example, this could be
+// used to implement a parsed-out $kind or $id.
+type MetaGetterSetter interface {
MetaGetter
// GetAllMeta returns a PropertyMap with all of the metadata in this
- // PropertyLoadSaver. If a metadata field has an error during serialization,
+ // MetaGetterSetter. If a metadata field has an error during serialization,
// it is skipped.
+ //
+ // If a *struct is implementing this, then it only needs to return the
+ // metadata fields which would be returned by its GetMeta implementation, and
+ // the `GetPLS` implementation will add any statically-defined metadata
+ // fields. So if GetMeta provides $id, but there's a simple tagged field for
+ // $kind, this method is only expected to return a PropertyMap with "$id".
GetAllMeta() PropertyMap
Vadim Sh. 2015/10/13 04:27:48 hm, why this isn't in MetaGetter?
iannucci 2015/10/13 04:34:40 It's... for not a super great reason. Basically wh
Vadim Sh. 2015/10/13 04:39:59 It just looks odd: *Setter (that extends Getter) a
// SetMeta allows you to set the current value of the meta-keyed field.
SetMeta(key string, val interface{}) error
-
- // Problem indicates that this PLS has a fatal problem. Usually this is
- // set when the underlying struct has recursion, invalid field types, nested
- // slices, etc.
- Problem() error
}
// PropertyMap represents the contents of a datastore entity in a generic way.

Powered by Google App Engine
This is Rietveld 408576698