Chromium Code Reviews| Index: logdog/appengine/coordinator/service.go |
| diff --git a/logdog/appengine/coordinator/service.go b/logdog/appengine/coordinator/service.go |
| index 08adae5053fac29a0e6e274356ee8b5ae30a6ce7..0ac16a2f0580cf4c6f01b3fcbc890c6ee52ee17f 100644 |
| --- a/logdog/appengine/coordinator/service.go |
| +++ b/logdog/appengine/coordinator/service.go |
| @@ -5,6 +5,7 @@ |
| package coordinator |
| import ( |
| + "net/http" |
| "sync" |
| "sync/atomic" |
| "time" |
| @@ -29,6 +30,7 @@ import ( |
| gcst "cloud.google.com/go/storage" |
| "golang.org/x/net/context" |
| "google.golang.org/api/option" |
| + "google.golang.org/appengine" |
| "google.golang.org/grpc" |
| "google.golang.org/grpc/metadata" |
| ) |
| @@ -88,7 +90,9 @@ type Services interface { |
| // |
| // It installs a production Services instance into the Context. |
| func ProdCoordinatorService(c *router.Context, next router.Handler) { |
| - c.Context = WithServices(c.Context, &prodServicesInst{}) |
| + c.Context = WithServices(c.Context, &prodServicesInst{ |
| + req: c.Request, |
| + }) |
| next(c) |
| } |
| @@ -97,6 +101,10 @@ func ProdCoordinatorService(c *router.Context, next router.Handler) { |
| type prodServicesInst struct { |
| sync.Mutex |
| + // req is the request that is being serviced. This is populated when the |
| + // service is installed via ProdCoordinatorService. |
| + req *http.Request |
| + |
| // gcfg is the cached global configuration. |
| gcfg *config.Config |
| projectConfigs map[luciConfig.ProjectName]*cachedProjectConfig |
| @@ -331,9 +339,12 @@ func (s *prodServicesInst) ArchivalPublisher(c context.Context) (ArchivalPublish |
| log.WithError(err).Errorf(c, "Failed to create Pub/Sub credentials.") |
| return nil, errors.New("failed to create Pub/Sub credentials") |
| } |
| + |
| + // Create a new AppEngine context. |
| + aeCtx := appengine.WithContext(metadata.NewContext(c, nil), s.req) |
| + |
| // Don't pass gRPC metadata to PubSub. |
|
Vadim Sh.
2016/12/18 21:40:10
nit: move this comment to the list 343.
|
| - psClient, err := gcps.NewClient( |
| - metadata.NewContext(c, nil), project, |
| + psClient, err := gcps.NewClient(aeCtx, project, |
| option.WithGRPCDialOption(grpc.WithPerRPCCredentials(creds))) |
| if err != nil { |
| log.WithError(err).Errorf(c, "Failed to create Pub/Sub client.") |