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...) 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 | |
Vadim Sh.
2016/12/20 21:25:15
this doesn't look like a part of this CL
| |
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 186 matching lines...) Loading... | |
462 // Stream is the signed URL for the log stream, if requested. | 463 // Stream is the signed URL for the log stream, if requested. |
463 Stream string | 464 Stream string |
464 // Index is the signed URL for the log stream index, if requested. | 465 // Index is the signed URL for the log stream index, if requested. |
465 Index string | 466 Index string |
466 } | 467 } |
467 | 468 |
468 // intermediateStorage is a Storage instance bound to BigTable. | 469 // intermediateStorage is a Storage instance bound to BigTable. |
469 type bigTableStorage struct { | 470 type bigTableStorage struct { |
470 // Storage is the base storage.Storage instance. | 471 // Storage is the base storage.Storage instance. |
471 storage.Storage | 472 storage.Storage |
473 // aeCtx is an AppEngine Context with "luci/gae" services also installed . This | |
474 // must be used for BigTable access in order to use the AppEngine socket s API. | |
475 aeCtx context.Context | |
472 } | 476 } |
473 | 477 |
474 func (*bigTableStorage) GetSignedURLs(context.Context, *URLSigningRequest) (*URL SigningResponse, error) { | 478 func (*bigTableStorage) GetSignedURLs(context.Context, *URLSigningRequest) (*URL SigningResponse, error) { |
475 return nil, nil | 479 return nil, nil |
476 } | 480 } |
477 | 481 |
478 type googleStorage struct { | 482 type googleStorage struct { |
479 // Storage is the base storage.Storage instance. | 483 // Storage is the base storage.Storage instance. |
480 storage.Storage | 484 storage.Storage |
481 // svc is the services instance that created this. | 485 // svc is the services instance that created this. |
(...skipping 66 matching lines...) Loading... | |
548 | 552 |
549 // Sign index URL. | 553 // Sign index URL. |
550 if req.Index { | 554 if req.Index { |
551 if resp.Index, err = doSign(si.index); err != nil { | 555 if resp.Index, err = doSign(si.index); err != nil { |
552 return nil, errors.Annotate(err).InternalReason("failed to sign index URL").Err() | 556 return nil, errors.Annotate(err).InternalReason("failed to sign index URL").Err() |
553 } | 557 } |
554 } | 558 } |
555 | 559 |
556 return &resp, nil | 560 return &resp, nil |
557 } | 561 } |
OLD | NEW |