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

Side by Side Diff: appengine/gaemiddleware/context.go

Issue 2575383002: Add server/cache support to gaeconfig. (Closed)
Patch Set: Un-collapse. 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 unified diff | Download patch
« no previous file with comments | « appengine/gaeconfig/settings.go ('k') | common/config/context.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 gaemiddleware 5 package gaemiddleware
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 9
10 "golang.org/x/net/context" 10 "golang.org/x/net/context"
11 "google.golang.org/appengine" 11 "google.golang.org/appengine"
12 12
13 "github.com/luci/gae/filter/dscache" 13 "github.com/luci/gae/filter/dscache"
14 "github.com/luci/gae/impl/prod" 14 "github.com/luci/gae/impl/prod"
15 "github.com/luci/gae/service/urlfetch" 15 "github.com/luci/gae/service/urlfetch"
16 16
17 "github.com/luci/luci-go/common/config"
18 "github.com/luci/luci-go/common/data/caching/cacheContext" 17 "github.com/luci/luci-go/common/data/caching/cacheContext"
19 "github.com/luci/luci-go/common/data/caching/proccache" 18 "github.com/luci/luci-go/common/data/caching/proccache"
20 "github.com/luci/luci-go/common/logging" 19 "github.com/luci/luci-go/common/logging"
21 20
22 "github.com/luci/luci-go/server/auth" 21 "github.com/luci/luci-go/server/auth"
23 "github.com/luci/luci-go/server/auth/authdb" 22 "github.com/luci/luci-go/server/auth/authdb"
24 "github.com/luci/luci-go/server/middleware" 23 "github.com/luci/luci-go/server/middleware"
25 "github.com/luci/luci-go/server/router" 24 "github.com/luci/luci-go/server/router"
26 "github.com/luci/luci-go/server/settings" 25 "github.com/luci/luci-go/server/settings"
27 26
28 "github.com/luci/luci-go/appengine/gaeauth/client" 27 "github.com/luci/luci-go/appengine/gaeauth/client"
29 "github.com/luci/luci-go/appengine/gaeauth/server" 28 "github.com/luci/luci-go/appengine/gaeauth/server"
30 "github.com/luci/luci-go/appengine/gaeauth/server/gaesigner" 29 "github.com/luci/luci-go/appengine/gaeauth/server/gaesigner"
31 "github.com/luci/luci-go/appengine/gaeconfig"
32 "github.com/luci/luci-go/appengine/gaesecrets" 30 "github.com/luci/luci-go/appengine/gaesecrets"
33 "github.com/luci/luci-go/appengine/gaesettings" 31 "github.com/luci/luci-go/appengine/gaesettings"
34 "github.com/luci/luci-go/appengine/tsmon" 32 "github.com/luci/luci-go/appengine/tsmon"
33 "github.com/luci/luci-go/luci_config/appengine/gaeconfig"
35 ) 34 )
36 35
37 var ( 36 var (
38 // globalProcessCache holds state cached between requests. 37 // globalProcessCache holds state cached between requests.
39 globalProcessCache = &proccache.Cache{} 38 globalProcessCache = &proccache.Cache{}
40 39
41 // globalSettings holds global app settings lazily updated from the data store. 40 // globalSettings holds global app settings lazily updated from the data store.
42 globalSettings = settings.New(gaesettings.Storage{}) 41 globalSettings = settings.New(gaesettings.Storage{})
43 42
44 // globalAuthConfig is configuration of the server/auth library. 43 // globalAuthConfig is configuration of the server/auth library.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 79
81 // Fetch and apply configuration stored in the datastore. 80 // Fetch and apply configuration stored in the datastore.
82 cachedSettings := fetchCachedSettings(c) 81 cachedSettings := fetchCachedSettings(c)
83 c = logging.SetLevel(c, cachedSettings.LoggingLevel) 82 c = logging.SetLevel(c, cachedSettings.LoggingLevel)
84 if !cachedSettings.DisableDSCache { 83 if !cachedSettings.DisableDSCache {
85 c = dscache.AlwaysFilterRDS(c) 84 c = dscache.AlwaysFilterRDS(c)
86 } 85 }
87 86
88 // The rest of the service may use applied configuration. 87 // The rest of the service may use applied configuration.
89 c = proccache.Use(c, globalProcessCache) 88 c = proccache.Use(c, globalProcessCache)
90 » c = config.SetImplementation(c, gaeconfig.New(c)) 89 » c = gaeconfig.Use(c)
91 c = gaesecrets.Use(c, nil) 90 c = gaesecrets.Use(c, nil)
92 c = auth.SetConfig(c, globalAuthConfig) 91 c = auth.SetConfig(c, globalAuthConfig)
93 92
94 // Wrap this in a cache context so that lookups for any of the aforement ioned 93 // Wrap this in a cache context so that lookups for any of the aforement ioned
95 // items are fast. 94 // items are fast.
96 return cacheContext.Wrap(c) 95 return cacheContext.Wrap(c)
97 } 96 }
98 97
99 // ProdServices is a middleware that installs the set of standard production 98 // ProdServices is a middleware that installs the set of standard production
100 // AppEngine services by calling WithProd. 99 // AppEngine services by calling WithProd.
(...skipping 16 matching lines...) Expand all
117 // BaseProd returns a list of middleware: WithProd middleware, a panic catcher i f this 116 // BaseProd returns a list of middleware: WithProd middleware, a panic catcher i f this
118 // is not a devserver, and the monitoring middleware. 117 // is not a devserver, and the monitoring middleware.
119 func BaseProd() router.MiddlewareChain { 118 func BaseProd() router.MiddlewareChain {
120 if appengine.IsDevAppServer() { 119 if appengine.IsDevAppServer() {
121 return router.NewMiddlewareChain(ProdServices, globalTsMonState. Middleware) 120 return router.NewMiddlewareChain(ProdServices, globalTsMonState. Middleware)
122 } 121 }
123 return router.NewMiddlewareChain( 122 return router.NewMiddlewareChain(
124 ProdServices, middleware.WithPanicCatcher, globalTsMonState.Midd leware, 123 ProdServices, middleware.WithPanicCatcher, globalTsMonState.Midd leware,
125 ) 124 )
126 } 125 }
OLDNEW
« no previous file with comments | « appengine/gaeconfig/settings.go ('k') | common/config/context.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698