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

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

Issue 2575383002: Add server/cache support to gaeconfig. (Closed)
Patch Set: Created 4 years 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
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
(...skipping 52 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 return cacheContext.Wrap(c) 92 return cacheContext.Wrap(c)
94 } 93 }
95 94
96 // ProdServices is a middleware that installs the set of standard production 95 // ProdServices is a middleware that installs the set of standard production
97 // AppEngine services by calling WithProd. 96 // AppEngine services by calling WithProd.
98 func ProdServices(c *router.Context, next router.Handler) { 97 func ProdServices(c *router.Context, next router.Handler) {
99 c.Context = WithProd(c.Context, c.Request) 98 c.Context = WithProd(c.Context, c.Request)
100 next(c) 99 next(c)
101 } 100 }
102 101
103 // BaseProd returns a list of middleware: WithProd middleware, a panic catcher i f this 102 // BaseProd returns a list of middleware: WithProd middleware, a panic catcher i f this
104 // is not a devserver, and the monitoring middleware. 103 // is not a devserver, and the monitoring middleware.
105 func BaseProd() router.MiddlewareChain { 104 func BaseProd() router.MiddlewareChain {
106 if appengine.IsDevAppServer() { 105 if appengine.IsDevAppServer() {
107 return router.NewMiddlewareChain(ProdServices, globalTsMonState. Middleware) 106 return router.NewMiddlewareChain(ProdServices, globalTsMonState. Middleware)
108 } 107 }
109 return router.NewMiddlewareChain( 108 return router.NewMiddlewareChain(
110 ProdServices, middleware.WithPanicCatcher, globalTsMonState.Midd leware, 109 ProdServices, middleware.WithPanicCatcher, globalTsMonState.Midd leware,
111 ) 110 )
112 } 111 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698