| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 package gae | |
| 6 | |
| 7 import ( | |
| 8 "time" | |
| 9 | |
| 10 "golang.org/x/net/context" | |
| 11 | |
| 12 "appengine" | |
| 13 | |
| 14 "infra/gae/libs/wrapper" | |
| 15 ) | |
| 16 | |
| 17 // useGI adds a wrapper.GlobalInfo implementation to context, accessible | |
| 18 // by wrapper.GetGI(c) | |
| 19 func useGI(c context.Context) context.Context { | |
| 20 return wrapper.SetGIFactory(c, func(ci context.Context) wrapper.GlobalIn
fo { | |
| 21 return giImpl{ctx(c).Context, ci} | |
| 22 }) | |
| 23 } | |
| 24 | |
| 25 type giImpl struct { | |
| 26 appengine.Context | |
| 27 ctx context.Context | |
| 28 } | |
| 29 | |
| 30 func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, e
rr error) { | |
| 31 return appengine.AccessToken(g, scopes...) | |
| 32 } | |
| 33 func (g giImpl) AppID() string { | |
| 34 return appengine.AppID(g) | |
| 35 } | |
| 36 func (g giImpl) Datacenter() string { | |
| 37 return appengine.Datacenter() | |
| 38 } | |
| 39 func (g giImpl) DefaultVersionHostname() string { | |
| 40 return appengine.DefaultVersionHostname(g) | |
| 41 } | |
| 42 func (g giImpl) InstanceID() string { | |
| 43 return appengine.InstanceID() | |
| 44 } | |
| 45 func (g giImpl) IsCapabilityDisabled(err error) bool { | |
| 46 return appengine.IsCapabilityDisabled(err) | |
| 47 } | |
| 48 func (g giImpl) IsDevAppserver() bool { | |
| 49 return appengine.IsDevAppServer() | |
| 50 } | |
| 51 func (g giImpl) IsOverQuota(err error) bool { | |
| 52 return appengine.IsOverQuota(err) | |
| 53 } | |
| 54 func (g giImpl) IsTimeoutError(err error) bool { | |
| 55 return appengine.IsTimeoutError(err) | |
| 56 } | |
| 57 func (g giImpl) ModuleHostname(module, version, instance string) (string, error)
{ | |
| 58 return appengine.ModuleHostname(g, module, version, instance) | |
| 59 } | |
| 60 func (g giImpl) ModuleName() (name string) { | |
| 61 return appengine.ModuleName(g) | |
| 62 } | |
| 63 func (g giImpl) Namespace(namespace string) (context.Context, error) { | |
| 64 gaeC, err := appengine.Namespace(g, namespace) | |
| 65 if err != nil { | |
| 66 return nil, err | |
| 67 } | |
| 68 return context.WithValue(g.ctx, goonContextKey, gaeC), nil | |
| 69 } | |
| 70 func (g giImpl) PublicCertificates() ([]appengine.Certificate, error) { | |
| 71 return appengine.PublicCertificates(g) | |
| 72 } | |
| 73 func (g giImpl) RequestID() string { | |
| 74 return appengine.RequestID(g) | |
| 75 } | |
| 76 func (g giImpl) ServerSoftware() string { | |
| 77 return appengine.ServerSoftware() | |
| 78 } | |
| 79 func (g giImpl) ServiceAccount() (string, error) { | |
| 80 return appengine.ServiceAccount(g) | |
| 81 } | |
| 82 func (g giImpl) SignBytes(bytes []byte) (keyName string, signature []byte, err e
rror) { | |
| 83 return appengine.SignBytes(g, bytes) | |
| 84 } | |
| 85 func (g giImpl) VersionID() string { | |
| 86 return appengine.VersionID(g) | |
| 87 } | |
| OLD | NEW |