| OLD | NEW | 
|    1 // Copyright 2016 The LUCI Authors. All rights reserved. |    1 // Copyright 2016 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 service |    5 package service | 
|    6  |    6  | 
|    7 import ( |    7 import ( | 
|    8         "flag" |    8         "flag" | 
|    9         "fmt" |    9         "fmt" | 
|   10         "net/http" |   10         "net/http" | 
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|   90         storageCredentialJSONPath string |   90         storageCredentialJSONPath string | 
|   91         cpuProfilePath            string |   91         cpuProfilePath            string | 
|   92         heapProfilePath           string |   92         heapProfilePath           string | 
|   93  |   93  | 
|   94         // onGCE is true if we're on GCE. We probe this exactly once. |   94         // onGCE is true if we're on GCE. We probe this exactly once. | 
|   95         onGCE bool |   95         onGCE bool | 
|   96  |   96  | 
|   97         killCheckInterval clockflag.Duration |   97         killCheckInterval clockflag.Duration | 
|   98         configFilePath    string |   98         configFilePath    string | 
|   99         serviceConfig     svcconfig.Config |   99         serviceConfig     svcconfig.Config | 
 |  100         configCache       config.ProcCache | 
|  100  |  101  | 
|  101         // serviceID is the cloud project ID, which is also this service's uniqu
     e |  102         // serviceID is the cloud project ID, which is also this service's uniqu
     e | 
|  102         // ID. This can be specified by flag or, if on GCE, will automatically b
     e |  103         // ID. This can be specified by flag or, if on GCE, will automatically b
     e | 
|  103         // probed from metadata. |  104         // probed from metadata. | 
|  104         serviceID string |  105         serviceID string | 
|  105  |  106  | 
|  106         coord logdog.ServicesClient |  107         coord logdog.ServicesClient | 
|  107 } |  108 } | 
|  108  |  109  | 
|  109 // Run performs service-wide initialization and invokes the specified run |  110 // Run performs service-wide initialization and invokes the specified run | 
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  407 // project configuration for proj. |  408 // project configuration for proj. | 
|  408 func (s *Service) ProjectConfigPath(proj cfgtypes.ProjectName) (cfgtypes.ConfigS
     et, string) { |  409 func (s *Service) ProjectConfigPath(proj cfgtypes.ProjectName) (cfgtypes.ConfigS
     et, string) { | 
|  409         return cfgtypes.ProjectConfigSet(proj), svcconfig.ProjectConfigPath(s.se
     rviceID) |  410         return cfgtypes.ProjectConfigSet(proj), svcconfig.ProjectConfigPath(s.se
     rviceID) | 
|  410 } |  411 } | 
|  411  |  412  | 
|  412 // ProjectConfig returns the current service's project configuration for proj. |  413 // ProjectConfig returns the current service's project configuration for proj. | 
|  413 func (s *Service) ProjectConfig(c context.Context, proj cfgtypes.ProjectName) (*
     svcconfig.ProjectConfig, error) { |  414 func (s *Service) ProjectConfig(c context.Context, proj cfgtypes.ProjectName) (*
     svcconfig.ProjectConfig, error) { | 
|  414         cset, path := s.ProjectConfigPath(proj) |  415         cset, path := s.ProjectConfigPath(proj) | 
|  415  |  416  | 
|  416         var pcfg svcconfig.ProjectConfig |  417         var pcfg svcconfig.ProjectConfig | 
|  417 »       if err := cfgclient.Get(c, cfgclient.AsService, cset, path, textproto.Me
     ssage(&pcfg), nil); err != nil { |  418 »       msg, err := s.configCache.GetTextProto(c, cset, path, &pcfg) | 
 |  419 »       if err != nil { | 
|  418                 return nil, errors.Annotate(err).Reason("failed to load project 
     config from %(cset)s.%(path)s"). |  420                 return nil, errors.Annotate(err).Reason("failed to load project 
     config from %(cset)s.%(path)s"). | 
|  419                         D("cset", cset).D("path", path).Err() |  421                         D("cset", cset).D("path", path).Err() | 
|  420         } |  422         } | 
|  421 »       return &pcfg, nil |  423 »       return msg.(*svcconfig.ProjectConfig), nil | 
|  422 } |  424 } | 
|  423  |  425  | 
|  424 // SetShutdownFunc sets the service shutdown function. |  426 // SetShutdownFunc sets the service shutdown function. | 
|  425 func (s *Service) SetShutdownFunc(f func()) { |  427 func (s *Service) SetShutdownFunc(f func()) { | 
|  426         s.shutdownFunc.Store(f) |  428         s.shutdownFunc.Store(f) | 
|  427 } |  429 } | 
|  428  |  430  | 
|  429 func (s *Service) shutdown() { |  431 func (s *Service) shutdown() { | 
|  430         v := s.shutdownFunc.Load() |  432         v := s.shutdownFunc.Load() | 
|  431         if f, ok := v.(func()); ok { |  433         if f, ok := v.(func()); ok { | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  557 // |  559 // | 
|  558 // An optional permutation function can be provided to modify those Options |  560 // An optional permutation function can be provided to modify those Options | 
|  559 // before the Authenticator is created. |  561 // before the Authenticator is created. | 
|  560 func (s *Service) TokenSource(c context.Context, f func(o *auth.Options)) (oauth
     2.TokenSource, error) { |  562 func (s *Service) TokenSource(c context.Context, f func(o *auth.Options)) (oauth
     2.TokenSource, error) { | 
|  561         a, err := s.Authenticator(c, f) |  563         a, err := s.Authenticator(c, f) | 
|  562         if err != nil { |  564         if err != nil { | 
|  563                 return nil, err |  565                 return nil, err | 
|  564         } |  566         } | 
|  565         return a.TokenSource() |  567         return a.TokenSource() | 
|  566 } |  568 } | 
| OLD | NEW |