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

Side by Side Diff: impl/prod/info.go

Issue 1766593002: Add a MustNamespace that panics if the namespace wasn't valid (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: Add MustNamespace to the interface Created 4 years, 9 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 | « impl/memory/info_test.go ('k') | service/info/interface.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 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 "time" 8 "time"
9 9
10 "github.com/luci/gae/service/info" 10 "github.com/luci/gae/service/info"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 func (g giImpl) Namespace(namespace string) (context.Context, error) { 70 func (g giImpl) Namespace(namespace string) (context.Context, error) {
71 aeCtx, err := appengine.Namespace(g.aeCtx, namespace) 71 aeCtx, err := appengine.Namespace(g.aeCtx, namespace)
72 if err != nil { 72 if err != nil {
73 return g.usrCtx, err 73 return g.usrCtx, err
74 } 74 }
75 usrCtx := context.WithValue(g.usrCtx, prodContextKey, aeCtx) 75 usrCtx := context.WithValue(g.usrCtx, prodContextKey, aeCtx)
76 pc := *getProbeCache(usrCtx) 76 pc := *getProbeCache(usrCtx)
77 pc.namespace = namespace 77 pc.namespace = namespace
78 return withProbeCache(usrCtx, &pc), nil 78 return withProbeCache(usrCtx, &pc), nil
79 } 79 }
80 func (g giImpl) MustNamespace(ns string) context.Context {
81 ret, err := g.Namespace(ns)
82 if err != nil {
83 panic(err)
84 }
85 return ret
86 }
80 func (g giImpl) PublicCertificates() ([]info.Certificate, error) { 87 func (g giImpl) PublicCertificates() ([]info.Certificate, error) {
81 certs, err := appengine.PublicCertificates(g.aeCtx) 88 certs, err := appengine.PublicCertificates(g.aeCtx)
82 if err != nil { 89 if err != nil {
83 return nil, err 90 return nil, err
84 } 91 }
85 ret := make([]info.Certificate, len(certs)) 92 ret := make([]info.Certificate, len(certs))
86 for i, c := range certs { 93 for i, c := range certs {
87 ret[i] = info.Certificate(c) 94 ret[i] = info.Certificate(c)
88 } 95 }
89 return ret, nil 96 return ret, nil
(...skipping 30 matching lines...) Expand all
120 func getProbeCache(c context.Context) *infoProbeCache { 127 func getProbeCache(c context.Context) *infoProbeCache {
121 if pc, ok := c.Value(probeCacheKey).(*infoProbeCache); ok { 128 if pc, ok := c.Value(probeCacheKey).(*infoProbeCache); ok {
122 return pc 129 return pc
123 } 130 }
124 return nil 131 return nil
125 } 132 }
126 133
127 func withProbeCache(c context.Context, pc *infoProbeCache) context.Context { 134 func withProbeCache(c context.Context, pc *infoProbeCache) context.Context {
128 return context.WithValue(c, probeCacheKey, pc) 135 return context.WithValue(c, probeCacheKey, pc)
129 } 136 }
OLDNEW
« no previous file with comments | « impl/memory/info_test.go ('k') | service/info/interface.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698