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

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

Issue 2275123002: Milo: pRPC endpoint for getting Buildbot master data (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/luci-go@master
Patch Set: Renamed stuff 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « milo/appengine/buildbot/builder.go ('k') | milo/appengine/buildbot/master.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
new file mode 100644
index 0000000000000000000000000000000000000000..3a8031cffc3112fcb1096f13326e6308494ad581
--- /dev/null
+++ b/milo/appengine/buildbot/grpc.go
@@ -0,0 +1,44 @@
+// Copyright 2016 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 buildbot
+
+import (
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/codes"
+
+ "github.com/luci/luci-go/common/proto/google"
+ milo "github.com/luci/luci-go/milo/api/proto"
+ "golang.org/x/net/context"
+)
+
+type BuildbotService struct{}
+
+var errNotFoundGRPC = grpc.Errorf(codes.NotFound, "Master Not Found")
+
+func (s *BuildbotService) GetCompressedMasterJSON(
+ c context.Context, req *milo.MasterRequest) (*milo.CompressedMasterJSON, error) {
+
+ if req.Name == "" {
+ return nil, grpc.Errorf(codes.InvalidArgument, "No master specified")
+ }
+
+ entry, err := getMasterEntry(c, req.Name)
+ switch {
+ case err == errMasterNotFound:
+ return nil, errNotFoundGRPC
+
+ case err != nil:
+ return nil, err
+ }
+
+ return &milo.CompressedMasterJSON{
+ Internal: entry.Internal,
+ Modified: &google.Timestamp{
+ Seconds: entry.Modified.Unix(),
+ Nanos: int32(entry.Modified.Nanosecond()),
+ },
+ Data: entry.Data,
+ }, nil
+}
« no previous file with comments | « milo/appengine/buildbot/builder.go ('k') | milo/appengine/buildbot/master.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698