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

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

Issue 2647083003: LogDog: Use luci_config/server packages for config (Closed)
Patch Set: Comments. 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/flag_test.go ('k') | logdog/server/service/service.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: logdog/server/service/config/opts.go
diff --git a/logdog/server/service/config/opts.go b/logdog/server/service/config/opts.go
new file mode 100644
index 0000000000000000000000000000000000000000..d26518b02a089326698795498fb683e1da2b8184
--- /dev/null
+++ b/logdog/server/service/config/opts.go
@@ -0,0 +1,39 @@
+// Copyright 2017 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package config
+
+import (
+ "time"
+
+ "github.com/luci/luci-go/luci_config/server/cfgclient/backend"
+ "github.com/luci/luci-go/luci_config/server/cfgclient/backend/caching"
+
+ "golang.org/x/net/context"
+)
+
+// CacheOptions is the set of configuration options.
+type CacheOptions struct {
+ // CacheExpiration is the amount of time that a config entry should be cached.
+ //
+ // If this value is <= 0, no configuration caching will be enabled. This
+ // should not be set for production systems.
+ CacheExpiration time.Duration
+}
+
+// WrapBackend wraps the supplied base backend in caching layers and returns a
+// Conext with the resulting backend installed.
+func (o *CacheOptions) WrapBackend(c context.Context, base backend.B) context.Context {
+ return backend.WithFactory(c, func(c context.Context) backend.B {
+ // Start with our base Backend.
+ be := base
+
+ // Add a proccache-based config cache.
+ if o.CacheExpiration > 0 {
+ be = caching.ProcCache(be, o.CacheExpiration)
+ }
+
+ return be
+ })
+}
« no previous file with comments | « logdog/server/service/config/flag_test.go ('k') | logdog/server/service/service.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698