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

Unified Diff: milo/buildsource/buildbucket/struct.go

Issue 2964143002: Buildbucket: Save buildbucket build info and summary on pubsub push (Closed)
Patch Set: nits 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
« no previous file with comments | « milo/buildsource/buildbucket/pubsub.go ('k') | milo/buildsource/swarming/build.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/buildsource/buildbucket/struct.go
diff --git a/milo/buildsource/buildbucket/struct.go b/milo/buildsource/buildbucket/struct.go
new file mode 100644
index 0000000000000000000000000000000000000000..0a234747da38a3f917010bf6945b8463bd50d9c1
--- /dev/null
+++ b/milo/buildsource/buildbucket/struct.go
@@ -0,0 +1,49 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package buildbucket
+
+import (
+ "encoding/json"
+ "fmt"
+ "time"
+
+ bucketApi "github.com/luci/luci-go/common/api/buildbucket/buildbucket/v1"
+ "github.com/luci/luci-go/milo/api/resp"
+)
+
+// buildEntry is a full buildbucket build along with its full resp rendering
+// at the time of modification. This is a parent of a BuildSummary.
+type buildEntry struct {
+ // key is formulated via <project ID>:<build ID>. From PubSub, project ID
+ // is determined via the topic name.
+ key string `gae:$id`
+
+ // buildData is the json marshalled form of
+ // a bucketApi.ApiCommonBuildMessage message.
+ buildbucketData []byte `gae:,noindex`
+
+ // respBuild is the resp.MiloBuild representation of the build.
+ respBuild *resp.MiloBuild `gae:,noindex`
+
+ // project is the luci project name of the build.
+ project string
+
+ // created is the time when this build entry was first created.
+ created time.Time
+
+ // last is the time when this build entry was last modified.
+ modified time.Time
+}
+
+// buildEntryKey returns the key for a build entry given a hostname and build ID.
+func buildEntryKey(host string, buildID int64) string {
+ return fmt.Sprintf("%s:%d", host, buildID)
+}
+
+func (b *buildEntry) getBuild() (*bucketApi.ApiCommonBuildMessage, error) {
+ msg := bucketApi.ApiCommonBuildMessage{}
+ err := json.Unmarshal(b.buildbucketData, &msg)
+ return &msg, err
+}
« no previous file with comments | « milo/buildsource/buildbucket/pubsub.go ('k') | milo/buildsource/swarming/build.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698