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

Unified Diff: appengine/logdog/coordinator/endpoints/logs/service.go

Issue 1909073002: LogDog: Add project namespace to logs endpoint. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-storage
Patch Set: Rebase? Created 4 years, 8 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: appengine/logdog/coordinator/endpoints/logs/service.go
diff --git a/appengine/logdog/coordinator/endpoints/logs/service.go b/appengine/logdog/coordinator/endpoints/logs/service.go
index 88f43c05d9a45f4124269be0727b9234bb204388..cda99e29400f4badf6787c95f4d098db711aea2f 100644
--- a/appengine/logdog/coordinator/endpoints/logs/service.go
+++ b/appengine/logdog/coordinator/endpoints/logs/service.go
@@ -6,7 +6,12 @@ package logs
import (
"github.com/golang/protobuf/proto"
+ "github.com/luci/luci-go/appengine/logdog/coordinator"
+ "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints"
"github.com/luci/luci-go/common/api/logdog_coordinator/logs/v1"
+ "github.com/luci/luci-go/common/config"
+ "github.com/luci/luci-go/common/grpcutil"
+ log "github.com/luci/luci-go/common/logging"
"golang.org/x/net/context"
)
@@ -28,6 +33,22 @@ func newService(svr *server) logdog.LogsServer {
return &logdog.DecoratedLogs{
Service: svr,
Prelude: func(c context.Context, methodName string, req proto.Message) (context.Context, error) {
+ // Enter a datastore namespace based on the message type.
+ //
+ // We use a type switch here because this is a shared decorator. All user
+ // mesages must implement ProjectBoundMessage.
+ pbm, ok := req.(endpoints.ProjectBoundMessage)
+ if !ok {
+ log.Fields{
+ "methodName": methodName,
+ }.Errorf(c, "Request (%T) does not expose a project namespace.", req)
+ return nil, grpcutil.Internal
+ }
+
+ if err := coordinator.WithProjectNamespace(&c, config.ProjectName(pbm.GetMessageProject())); err != nil {
+ return nil, grpcutil.Internal
+ }
+
return c, nil
},
}
« no previous file with comments | « appengine/logdog/coordinator/endpoints/logs/query_test.go ('k') | common/api/logdog_coordinator/logs/v1/logs.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698