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

Unified Diff: common/api/dm/service/v1/datastore_embed.go

Issue 1537883002: Initial distributor implementation (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: self review Created 4 years, 6 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: common/api/dm/service/v1/datastore_embed.go
diff --git a/common/api/dm/service/v1/datastore_embed.go b/common/api/dm/service/v1/datastore_embed.go
index 7ac472371a07fcf095790f26e77633d547f6f2af..dc4a8dee434854259a8db0aa4bb33c4b1f4bbbcd 100644
--- a/common/api/dm/service/v1/datastore_embed.go
+++ b/common/api/dm/service/v1/datastore_embed.go
@@ -15,7 +15,6 @@ import (
const flipMask uint32 = 0xFFFFFFFF
var _ datastore.PropertyConverter = (*Attempt_ID)(nil)
-var _ datastore.PropertyConverter = (*Execution_ID)(nil)
// NewQuestID is a shorthand to New a new *Quest_ID
func NewQuestID(qst string) *Quest_ID {
@@ -75,54 +74,6 @@ func (a *Attempt_ID) SetDMEncoded(val string) error {
return nil
}
-// ToProperty implements datastore.PropertyConverter for the purpose of
-// embedding this Execution_ID as the ID of a luci/gae compatible datastore
-// object. The numerical id field is stored as an inverted, hex-encoded string,
-// so that Execution_ID{"quest", 1, 2} would encode as "quest|fffffffe|fffffffd".
-// This is done so that the __key__ ordering in the dm application prefers to
-// order the most recent executions first.
-//
-// The go representation will always have the normal non-flipped numerical ids.
-func (e *Execution_ID) ToProperty() (datastore.Property, error) {
- return datastore.MkPropertyNI(e.DMEncoded()), nil
-}
-
-// FromProperty implements datastore.PropertyConverter
-func (e *Execution_ID) FromProperty(p datastore.Property) error {
- if p.Type() != datastore.PTString {
- return fmt.Errorf("wrong type for property: %s", p.Type())
- }
- return e.SetDMEncoded(p.Value().(string))
-}
-
-// DMEncoded returns the encoded inverted string id for this Execution. Numeric
-// values are inverted if flip is true.
-func (e *Execution_ID) DMEncoded() string {
- return fmt.Sprintf("%s|%08x|%08x", e.Quest, flipMask^e.Attempt, flipMask^e.Id)
-}
-
-// SetDMEncoded decodes val into this Execution_ID, returning an error if
-// there's a problem. Numeric values are inverted if flip is true.
-func (e *Execution_ID) SetDMEncoded(val string) error {
- toks := strings.SplitN(val, "|", 3)
- if len(toks) != 3 {
- return fmt.Errorf("unable to parse Execution id: %q", val)
- }
- an, err := strconv.ParseUint(toks[1], 16, 32)
- if err != nil {
- return err
- }
- en, err := strconv.ParseUint(toks[2], 16, 32)
- if err != nil {
- return err
- }
-
- e.Quest = toks[0]
- e.Attempt = flipMask ^ uint32(an)
- e.Id = flipMask ^ uint32(en)
- return nil
-}
-
// GetQuest gets the specified quest from GraphData, if it's already there. If
// it's not, then a new Quest will be created, added, and returned.
//
@@ -143,8 +94,8 @@ func (g *GraphData) GetQuest(qid string) (*Quest, bool) {
}
// NewQuestDesc is a shorthand method for building a new *Quest_Desc.
-func NewQuestDesc(cfg string, js string) *Quest_Desc {
- return &Quest_Desc{cfg, js}
+func NewQuestDesc(cfg string, js string, meta *Quest_Desc_Meta) *Quest_Desc {
+ return &Quest_Desc{cfg, js, meta}
}
// NewTemplateSpec is a shorthand method for building a new *Quest_TemplateSpec.

Powered by Google App Engine
This is Rietveld 408576698