Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(811)

Unified Diff: logdog/server/service/service.go

Issue 2648033002: LogDog: Use live object cache for configs. (Closed)
Patch Set: Renaming, actually use it :/ Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « logdog/server/service/config/cache.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/server/service/service.go
diff --git a/logdog/server/service/service.go b/logdog/server/service/service.go
index 5746fceadb051214ca22415c5e1bc54c2b9becc7..ab55f4cd26fdf7de5958705ccb8f5eff34d571bd 100644
--- a/logdog/server/service/service.go
+++ b/logdog/server/service/service.go
@@ -108,6 +108,7 @@ type Service struct {
testConfigFilePath string
// serviceConfig is the cached service configuration.
serviceConfig svcconfig.Config
+ configCache config.MessageCache
// serviceID is the cloud project ID, which is also this service's unique
// ID. This can be specified by flag or, if on GCE, will automatically be
@@ -331,9 +332,8 @@ func (s *Service) initCoordinatorClient(c context.Context) (logdog.ServicesClien
}
func (s *Service) initConfig(c *context.Context) error {
- opts := config.CacheOptions{
- CacheExpiration: projectConfigCacheDuration,
- }
+ // Set up our in-memory config object cache.
+ s.configCache.Lifetime = projectConfigCacheDuration
// If a testConfigFilePath was specified, use a mock configuration service
// that loads from a local file.
@@ -380,6 +380,9 @@ func (s *Service) initConfig(c *context.Context) error {
}
// Add config caching layers.
+ opts := config.CacheOptions{
+ CacheExpiration: projectConfigCacheDuration,
+ }
*c = opts.WrapBackend(*c, &client.Backend{
Provider: p,
})
@@ -432,11 +435,12 @@ func (s *Service) ProjectConfig(c context.Context, proj cfgtypes.ProjectName) (*
cset, path := s.ProjectConfigPath(proj)
var pcfg svcconfig.ProjectConfig
- if err := cfgclient.Get(c, cfgclient.AsService, cset, path, textproto.Message(&pcfg), nil); err != nil {
+ msg, err := s.configCache.Get(c, cset, path, &pcfg)
+ if err != nil {
return nil, errors.Annotate(err).Reason("failed to load project config from %(cset)s.%(path)s").
D("cset", cset).D("path", path).Err()
}
- return &pcfg, nil
+ return msg.(*svcconfig.ProjectConfig), nil
}
// SetShutdownFunc sets the service shutdown function.
« no previous file with comments | « logdog/server/service/config/cache.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698