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

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: Update config tests Created 4 years, 4 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
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..e6518bfc97a0c3ba36cdd009bb1d6885daa74604
--- /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) GetMaster(
+ c context.Context, req *milo.MasterRequest) (*milo.MasterReply, 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.MasterReply{
+ Internal: entry.Internal,
+ Modified: &google.Timestamp{
+ Seconds: entry.Modified.Unix(),
+ Nanos: int32(entry.Modified.Nanosecond()),
+ },
+ Data: entry.Data,
+ }, nil
+}

Powered by Google App Engine
This is Rietveld 408576698