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

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

Issue 1910923002: LogDog: Add project namespace to service endpoint. (Closed) Base URL: https://github.com/luci/luci-go@logdog-project-coordinator-backend
Patch Set: Comments. 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/services/service.go
diff --git a/appengine/logdog/coordinator/endpoints/services/service.go b/appengine/logdog/coordinator/endpoints/services/service.go
index cf4e37403bf31c2365bd600cead3aba080074f61..1be8d13d2038ce87e423146154aac0f14b93eb4c 100644
--- a/appengine/logdog/coordinator/endpoints/services/service.go
+++ b/appengine/logdog/coordinator/endpoints/services/service.go
@@ -7,7 +7,9 @@ package services
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/services/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"
@@ -34,6 +36,16 @@ func New() logdog.ServicesServer {
}
return nil, grpcutil.PermissionDenied
}
+
+ // Enter a datastore namespace based on the message type.
+ //
+ // We use a type switch here because this is a shared decorator.
+ if pbm, ok := req.(endpoints.ProjectBoundMessage); ok {
+ if err := coordinator.WithProjectNamespace(&c, config.ProjectName(pbm.GetMessageProject())); err != nil {
+ return nil, grpcutil.Internal
+ }
+ }
+
return c, nil
},
}

Powered by Google App Engine
This is Rietveld 408576698