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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « milo/buildsource/buildbucket/pubsub.go ('k') | milo/buildsource/swarming/build.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2017 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package buildbucket
6
7 import (
8 "encoding/json"
9 "fmt"
10 "time"
11
12 bucketApi "github.com/luci/luci-go/common/api/buildbucket/buildbucket/v1 "
13 "github.com/luci/luci-go/milo/api/resp"
14 )
15
16 // buildEntry is a full buildbucket build along with its full resp rendering
17 // at the time of modification. This is a parent of a BuildSummary.
18 type buildEntry struct {
19 // key is formulated via <project ID>:<build ID>. From PubSub, project ID
20 // is determined via the topic name.
21 key string `gae:$id`
22
23 // buildData is the json marshalled form of
24 // a bucketApi.ApiCommonBuildMessage message.
25 buildbucketData []byte `gae:,noindex`
26
27 // respBuild is the resp.MiloBuild representation of the build.
28 respBuild *resp.MiloBuild `gae:,noindex`
29
30 // project is the luci project name of the build.
31 project string
32
33 // created is the time when this build entry was first created.
34 created time.Time
35
36 // last is the time when this build entry was last modified.
37 modified time.Time
38 }
39
40 // buildEntryKey returns the key for a build entry given a hostname and build ID .
41 func buildEntryKey(host string, buildID int64) string {
42 return fmt.Sprintf("%s:%d", host, buildID)
43 }
44
45 func (b *buildEntry) getBuild() (*bucketApi.ApiCommonBuildMessage, error) {
46 msg := bucketApi.ApiCommonBuildMessage{}
47 err := json.Unmarshal(b.buildbucketData, &msg)
48 return &msg, err
49 }
OLDNEW
« 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