| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package prod | 5 package prod |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "net/http/cookiejar" | 10 "net/http/cookiejar" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 } | 63 } |
| 64 if deadline, ok := c.Deadline(); ok { | 64 if deadline, ok := c.Deadline(); ok { |
| 65 aeCtx, _ = context.WithDeadline(aeCtx, deadline) | 65 aeCtx, _ = context.WithDeadline(aeCtx, deadline) |
| 66 } | 66 } |
| 67 return aeCtx | 67 return aeCtx |
| 68 } | 68 } |
| 69 | 69 |
| 70 func setupAECtx(c, aeCtx context.Context) context.Context { | 70 func setupAECtx(c, aeCtx context.Context) context.Context { |
| 71 c = context.WithValue(c, prodContextKey, aeCtx) | 71 c = context.WithValue(c, prodContextKey, aeCtx) |
| 72 c = context.WithValue(c, prodContextNoTxnKey, aeCtx) | 72 c = context.WithValue(c, prodContextNoTxnKey, aeCtx) |
| 73 » return useMail(useUser(useURLFetch(useRDS(useMC(useTQ(useGI(useLogging(c
)))))))) | 73 » return useModule(useMail(useUser(useURLFetch(useRDS(useMC(useTQ(useGI(us
eLogging(c))))))))) |
| 74 } | 74 } |
| 75 | 75 |
| 76 // Use adds production implementations for all the gae services to the | 76 // Use adds production implementations for all the gae services to the |
| 77 // context. | 77 // context. |
| 78 // | 78 // |
| 79 // The services added are: | 79 // The services added are: |
| 80 // - github.com/luci-go/common/logging | 80 // - github.com/luci-go/common/logging |
| 81 // - github.com/luci/gae/service/datastore | 81 // - github.com/luci/gae/service/datastore |
| 82 // - github.com/luci/gae/service/info | 82 // - github.com/luci/gae/service/info |
| 83 // - github.com/luci/gae/service/mail | 83 // - github.com/luci/gae/service/mail |
| 84 // - github.com/luci/gae/service/memcache | 84 // - github.com/luci/gae/service/memcache |
| 85 // - github.com/luci/gae/service/module |
| 85 // - github.com/luci/gae/service/taskqueue | 86 // - github.com/luci/gae/service/taskqueue |
| 86 // - github.com/luci/gae/service/urlfetch | 87 // - github.com/luci/gae/service/urlfetch |
| 87 // - github.com/luci/gae/service/user | 88 // - github.com/luci/gae/service/user |
| 88 // | 89 // |
| 89 // These can be retrieved with the <service>.Get functions. | 90 // These can be retrieved with the <service>.Get functions. |
| 90 // | 91 // |
| 91 // The implementations are all backed by the real appengine SDK functionality, | 92 // The implementations are all backed by the real appengine SDK functionality, |
| 92 func Use(c context.Context, r *http.Request) context.Context { | 93 func Use(c context.Context, r *http.Request) context.Context { |
| 93 return setupAECtx(c, appengine.NewContext(r)) | 94 return setupAECtx(c, appengine.NewContext(r)) |
| 94 } | 95 } |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 } | 154 } |
| 154 } | 155 } |
| 155 | 156 |
| 156 aeCtx, err := remote_api.NewRemoteContext(host, client) | 157 aeCtx, err := remote_api.NewRemoteContext(host, client) |
| 157 if err != nil { | 158 if err != nil { |
| 158 return | 159 return |
| 159 } | 160 } |
| 160 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) | 161 *inOutCtx = setupAECtx(*inOutCtx, aeCtx) |
| 161 return nil | 162 return nil |
| 162 } | 163 } |
| OLD | NEW |