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

Side by Side Diff: milo/appengine/buildbot/grpc.go

Issue 2366763002: Milo: Grpc endpoint for multiple builds on a builder (Closed)
Patch Set: Created 4 years, 3 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/api/proto/pb.discovery.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package buildbot 5 package buildbot
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "compress/gzip" 9 "compress/gzip"
10 "encoding/json" 10 "encoding/json"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 46
47 bs, err := json.Marshal(b) 47 bs, err := json.Marshal(b)
48 if err != nil { 48 if err != nil {
49 return nil, err 49 return nil, err
50 } 50 }
51 51
52 // Marshal the build back into JSON format. 52 // Marshal the build back into JSON format.
53 return &milo.BuildbotBuildJSON{Data: bs}, nil 53 return &milo.BuildbotBuildJSON{Data: bs}, nil
54 } 54 }
55 55
56 func (s *Service) GetBuildbotBuildsJSON(
martiniss 2016/10/06 21:18:56 Can you add a basic smoke test or two for this?
hinoka 2016/10/07 01:44:54 Done.
57 c context.Context, req *milo.BuildbotBuildsRequest) (
58 *milo.BuildbotBuildsJSON, error) {
59
60 if req.Master == "" {
61 return nil, grpc.Errorf(codes.InvalidArgument, "No master specif ied")
62 }
63 if req.Builder == "" {
64 return nil, grpc.Errorf(codes.InvalidArgument, "No builder speci fied")
65 }
66
67 // Perform an ACL check by fetching the master.
68 _, err := getMasterEntry(c, req.Master)
69 switch {
70 case err == errMasterNotFound:
71 return nil, grpc.Errorf(codes.NotFound, "Master not found")
72 case err != nil:
73 return nil, err
74 }
75
76 limit := req.Limit
77 if limit == 0 {
78 limit = 50
martiniss 2016/10/06 21:18:56 buildbot default limit is 20, why not replicate th
hinoka 2016/10/07 01:44:54 test-results used 50 i think. Both are equally ar
79 }
80
81 q := ds.NewQuery("buildbotBuild")
82 q = q.Eq("master", req.Master).
83 Eq("builder", req.Builder).
84 Eq("finished", true).
martiniss 2016/10/06 21:18:56 Do we want to always require finished? Can we make
hinoka 2016/10/07 01:44:54 Done.
85 Limit(limit).
86 Order("-number")
87 builds := []*buildbotBuild{}
88 err = ds.GetAll(c, q, &builds)
89 if err != nil {
90 return nil, err
91 }
92
93 results := make([]*milo.BuildbotBuildJSON, len(builds))
94 for i, b := range builds {
95 // In theory we could do this in parallel, but it doesn't actual ly go faster
96 // since AppEngine is single-cored.
97 bs, err := json.Marshal(b)
98 if err != nil {
99 return nil, err
100 }
101 results[i] = &milo.BuildbotBuildJSON{Data: bs}
102 }
103 return &milo.BuildbotBuildsJSON{
104 Builds: results,
martiniss 2016/10/06 21:18:56 Is this going to run into app engine response size
hinoka 2016/10/07 01:44:54 Unlikely I think. The main issue we run into usua
105 }, nil
106 }
107
56 // GetCompressedMasterJSON assembles a CompressedMasterJSON object from the 108 // GetCompressedMasterJSON assembles a CompressedMasterJSON object from the
57 // provided MasterRequest. 109 // provided MasterRequest.
58 func (s *Service) GetCompressedMasterJSON( 110 func (s *Service) GetCompressedMasterJSON(
59 c context.Context, req *milo.MasterRequest) (*milo.CompressedMasterJSON, error) { 111 c context.Context, req *milo.MasterRequest) (*milo.CompressedMasterJSON, error) {
60 112
61 if req.Name == "" { 113 if req.Name == "" {
62 return nil, grpc.Errorf(codes.InvalidArgument, "No master specif ied") 114 return nil, grpc.Errorf(codes.InvalidArgument, "No master specif ied")
63 } 115 }
64 116
65 entry, err := getMasterEntry(c, req.Name) 117 entry, err := getMasterEntry(c, req.Name)
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 187
136 return &milo.CompressedMasterJSON{ 188 return &milo.CompressedMasterJSON{
137 Internal: entry.Internal, 189 Internal: entry.Internal,
138 Modified: &google.Timestamp{ 190 Modified: &google.Timestamp{
139 Seconds: entry.Modified.Unix(), 191 Seconds: entry.Modified.Unix(),
140 Nanos: int32(entry.Modified.Nanosecond()), 192 Nanos: int32(entry.Modified.Nanosecond()),
141 }, 193 },
142 Data: gzbs.Bytes(), 194 Data: gzbs.Bytes(),
143 }, nil 195 }, nil
144 } 196 }
OLDNEW
« no previous file with comments | « milo/api/proto/pb.discovery.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698