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

Unified Diff: milo/appengine/buildbot/grpc.go

Issue 2366763002: Milo: Grpc endpoint for multiple builds on a builder (Closed)
Patch Set: Review comments, add smoke test Created 4 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
« no previous file with comments | « milo/api/proto/pb.discovery.go ('k') | milo/appengine/buildbot/grpc_test.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/appengine/buildbot/grpc.go
diff --git a/milo/appengine/buildbot/grpc.go b/milo/appengine/buildbot/grpc.go
index 5b696b864baeb60e4275093c7e4ac005cfef550a..f63b69fa88566fb67867910b55454e6be9c097e8 100644
--- a/milo/appengine/buildbot/grpc.go
+++ b/milo/appengine/buildbot/grpc.go
@@ -53,6 +53,60 @@ func (s *Service) GetBuildbotBuildJSON(
return &milo.BuildbotBuildJSON{Data: bs}, nil
}
+func (s *Service) GetBuildbotBuildsJSON(
+ c context.Context, req *milo.BuildbotBuildsRequest) (
+ *milo.BuildbotBuildsJSON, error) {
+
+ if req.Master == "" {
+ return nil, grpc.Errorf(codes.InvalidArgument, "No master specified")
+ }
+ if req.Builder == "" {
+ return nil, grpc.Errorf(codes.InvalidArgument, "No builder specified")
+ }
+
+ // Perform an ACL check by fetching the master.
+ _, err := getMasterEntry(c, req.Master)
+ switch {
+ case err == errMasterNotFound:
+ return nil, grpc.Errorf(codes.NotFound, "Master not found")
+ case err != nil:
+ return nil, err
+ }
+
+ limit := req.Limit
+ if limit == 0 {
+ limit = 20
+ }
+
+ q := ds.NewQuery("buildbotBuild")
+ q = q.Eq("master", req.Master).
+ Eq("builder", req.Builder).
+ Limit(limit).
+ Order("-number")
+ if req.IncludeCurrent == false {
+ q = q.Eq("finished", true)
+ }
+ builds := []*buildbotBuild{}
+ err = ds.GetAll(c, q, &builds)
+ if err != nil {
+ return nil, err
+ }
+
+ results := make([]*milo.BuildbotBuildJSON, len(builds))
+ for i, b := range builds {
+ // In theory we could do this in parallel, but it doesn't actually go faster
+ // since AppEngine is single-cored.
+ bs, err := json.Marshal(b)
+ if err != nil {
+ return nil, err
+ }
+ results[i] = &milo.BuildbotBuildJSON{Data: bs}
+ }
+ return &milo.BuildbotBuildsJSON{
+ Builds: results,
+ }, nil
+}
+
// GetCompressedMasterJSON assembles a CompressedMasterJSON object from the
// provided MasterRequest.
func (s *Service) GetCompressedMasterJSON(
« no previous file with comments | « milo/api/proto/pb.discovery.go ('k') | milo/appengine/buildbot/grpc_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698