| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package coordinator | 5 package coordinator |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "sync" | 8 "sync" |
| 9 "sync/atomic" | 9 "sync/atomic" |
| 10 "time" | 10 "time" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return nil, merr | 250 return nil, merr |
| 251 } | 251 } |
| 252 | 252 |
| 253 // Get an Authenticator bound to the token scopes that we need for BigTa
ble. | 253 // Get an Authenticator bound to the token scopes that we need for BigTa
ble. |
| 254 creds, err := auth.GetPerRPCCredentials(auth.AsSelf, auth.WithScopes(big
table.StorageScopes...)) | 254 creds, err := auth.GetPerRPCCredentials(auth.AsSelf, auth.WithScopes(big
table.StorageScopes...)) |
| 255 if err != nil { | 255 if err != nil { |
| 256 log.WithError(err).Errorf(c, "Failed to create BigTable credenti
als.") | 256 log.WithError(err).Errorf(c, "Failed to create BigTable credenti
als.") |
| 257 return nil, errors.New("failed to create BigTable credentials") | 257 return nil, errors.New("failed to create BigTable credentials") |
| 258 } | 258 } |
| 259 | 259 |
| 260 // Use an AppEngine Context so we have access to the socket API. This is | |
| 261 // needed by AppEngine Classic for gRPC connections. | |
| 262 // | |
| 263 // Explicitly clear gRPC metadata from the Context. It is forwarded to | 260 // Explicitly clear gRPC metadata from the Context. It is forwarded to |
| 264 // delegate calls by default, and standard request metadata can break Bi
gTable | 261 // delegate calls by default, and standard request metadata can break Bi
gTable |
| 265 // calls. | 262 // calls. |
| 266 » st, err := bigtable.New(metadata.NewContext(s.aeCtx, nil), bigtable.Opti
ons{ | 263 » c = metadata.NewContext(c, nil) |
| 264 |
| 265 » st, err := bigtable.New(c, bigtable.Options{ |
| 267 Project: bt.Project, | 266 Project: bt.Project, |
| 268 Instance: bt.Instance, | 267 Instance: bt.Instance, |
| 269 LogTable: bt.LogTableName, | 268 LogTable: bt.LogTableName, |
| 270 ClientOptions: []option.ClientOption{ | 269 ClientOptions: []option.ClientOption{ |
| 271 option.WithGRPCDialOption(grpc.WithPerRPCCredentials(cre
ds)), | 270 option.WithGRPCDialOption(grpc.WithPerRPCCredentials(cre
ds)), |
| 272 }, | 271 }, |
| 273 Cache: s.getStorageCache(), | 272 Cache: s.getStorageCache(), |
| 274 }) | 273 }) |
| 275 if err != nil { | 274 if err != nil { |
| 276 log.WithError(err).Errorf(c, "Failed to create BigTable instance
.") | 275 log.WithError(err).Errorf(c, "Failed to create BigTable instance
.") |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 549 | 548 |
| 550 // Sign index URL. | 549 // Sign index URL. |
| 551 if req.Index { | 550 if req.Index { |
| 552 if resp.Index, err = doSign(si.index); err != nil { | 551 if resp.Index, err = doSign(si.index); err != nil { |
| 553 return nil, errors.Annotate(err).InternalReason("failed
to sign index URL").Err() | 552 return nil, errors.Annotate(err).InternalReason("failed
to sign index URL").Err() |
| 554 } | 553 } |
| 555 } | 554 } |
| 556 | 555 |
| 557 return &resp, nil | 556 return &resp, nil |
| 558 } | 557 } |
| OLD | NEW |