| 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 // |
| 260 // Explicitly clear gRPC metadata from the Context. It is forwarded to | 263 // Explicitly clear gRPC metadata from the Context. It is forwarded to |
| 261 // delegate calls by default, and standard request metadata can break Bi
gTable | 264 // delegate calls by default, and standard request metadata can break Bi
gTable |
| 262 // calls. | 265 // calls. |
| 263 » c = metadata.NewContext(c, nil) | 266 » st, err := bigtable.New(metadata.NewContext(s.aeCtx, nil), bigtable.Opti
ons{ |
| 264 | |
| 265 » st, err := bigtable.New(c, bigtable.Options{ | |
| 266 Project: bt.Project, | 267 Project: bt.Project, |
| 267 Instance: bt.Instance, | 268 Instance: bt.Instance, |
| 268 LogTable: bt.LogTableName, | 269 LogTable: bt.LogTableName, |
| 269 ClientOptions: []option.ClientOption{ | 270 ClientOptions: []option.ClientOption{ |
| 270 option.WithGRPCDialOption(grpc.WithPerRPCCredentials(cre
ds)), | 271 option.WithGRPCDialOption(grpc.WithPerRPCCredentials(cre
ds)), |
| 271 }, | 272 }, |
| 272 Cache: s.getStorageCache(), | 273 Cache: s.getStorageCache(), |
| 273 }) | 274 }) |
| 274 if err != nil { | 275 if err != nil { |
| 275 log.WithError(err).Errorf(c, "Failed to create BigTable instance
.") | 276 log.WithError(err).Errorf(c, "Failed to create BigTable instance
.") |
| (...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 | 549 |
| 549 // Sign index URL. | 550 // Sign index URL. |
| 550 if req.Index { | 551 if req.Index { |
| 551 if resp.Index, err = doSign(si.index); err != nil { | 552 if resp.Index, err = doSign(si.index); err != nil { |
| 552 return nil, errors.Annotate(err).InternalReason("failed
to sign index URL").Err() | 553 return nil, errors.Annotate(err).InternalReason("failed
to sign index URL").Err() |
| 553 } | 554 } |
| 554 } | 555 } |
| 555 | 556 |
| 556 return &resp, nil | 557 return &resp, nil |
| 557 } | 558 } |
| OLD | NEW |