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

Unified Diff: milo/common/model/build_summary.go

Issue 2978293002: [milo] Add an (uncached) method to get console rows. (Closed)
Patch Set: Created 3 years, 5 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: milo/common/model/build_summary.go
diff --git a/milo/common/model/build_summary.go b/milo/common/model/build_summary.go
index ac7f09dd2a5d60498682eb9dfe7baf21149f7ecb..f806780160297fd703a69acf8a7ed032cea2e496 100644
--- a/milo/common/model/build_summary.go
+++ b/milo/common/model/build_summary.go
@@ -82,12 +82,31 @@ type BuildSummary struct {
// It's up to the caller to ensure that entries in ManifestRevisionIndex aren't
// duplicated.
func (bs *BuildSummary) AddManifestRevisionIndex(project, console, manifest, repoURL string, revision []byte) {
+ bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex,
+ BuildSummaryPrefix(project, console, manifest, repoURL).AddRevision(revision))
+}
+
+// ManifestRevisionIndexPrefix is a binary prefix for querying
Ryan Tseng 2017/07/19 08:07:58 Holy long names batman (not in the size of the nam
iannucci 2017/07/20 00:14:56 Done.
+// BuildSummary.ManifestRevisionIndex obtained from BuildSummaryPrefix.
+type ManifestRevisionIndexPrefix []byte
+
+// AddRevision appends a git revision (as bytes) to the
+// ManifestRevisionIndexPrefix, returning a full index value.
+func (m ManifestRevisionIndexPrefix) AddRevision(revision []byte) []byte {
+ var buf bytes.Buffer
+ buf.Write(m)
+ cmpbin.WriteBytes(&buf, revision)
+ return buf.Bytes()
+}
+
+// BuildSummaryPrefix generates a ManifestRevisionIndex prefix corresponding to
+// the given parameters.
+func BuildSummaryPrefix(project, console, manifest, repoURL string) ManifestRevisionIndexPrefix {
var buf bytes.Buffer
cmpbin.WriteUint(&buf, 0) // version
cmpbin.WriteString(&buf, project)
cmpbin.WriteString(&buf, console)
cmpbin.WriteString(&buf, manifest)
cmpbin.WriteString(&buf, repoURL)
- cmpbin.WriteBytes(&buf, revision)
- bs.ManifestRevisionIndex = append(bs.ManifestRevisionIndex, buf.Bytes())
+ return ManifestRevisionIndexPrefix(buf.Bytes())
}

Powered by Google App Engine
This is Rietveld 408576698