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

Unified Diff: go/src/infra/gae/libs/wrapper/gae/globalinfo.go

Issue 1151473003: Better attempt at an appengine wrapper. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: pointer! Created 5 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: go/src/infra/gae/libs/wrapper/gae/globalinfo.go
diff --git a/go/src/infra/gae/libs/wrapper/gae/globalinfo.go b/go/src/infra/gae/libs/wrapper/gae/globalinfo.go
new file mode 100644
index 0000000000000000000000000000000000000000..c003c4f94311cbc590bbb907981e76edf70fce45
--- /dev/null
+++ b/go/src/infra/gae/libs/wrapper/gae/globalinfo.go
@@ -0,0 +1,73 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package gae
+
+import (
+ "time"
+
+ "golang.org/x/net/context"
+
+ "appengine"
+
+ "infra/gae/libs/wrapper"
+)
+
+// UseGI adds a wrapper.GlobalInfo implementation to context, accessible
+// by wrapper.GetGI(c)
+func UseGI(c context.Context) context.Context {
+ return wrapper.SetGIFactory(c, func(ci context.Context) wrapper.GlobalInfo {
+ return giImpl{ctx(c).Context, ci}
+ })
+}
+
+type giImpl struct {
+ appengine.Context
+ ctx context.Context
+}
+
+func (g giImpl) AccessToken(scopes ...string) (token string, expiry time.Time, err error) {
+ return appengine.AccessToken(g, scopes...)
+}
+func (g giImpl) AppID() string {
+ return appengine.AppID(g)
+}
+func (g giImpl) ModuleHostname(module, version, instance string) (string, error) {
+ return appengine.ModuleHostname(g, module, version, instance)
+}
+func (g giImpl) ModuleName() (name string) {
+ return appengine.ModuleName(g)
+}
+func (g giImpl) DefaultVersionHostname() string {
M-A Ruel 2015/05/25 17:14:52 I think I'd prefer to have the methods in alphabet
iannucci 2015/05/26 18:25:06 done
+ return appengine.DefaultVersionHostname(g)
+}
+func (g giImpl) PublicCertificates() ([]appengine.Certificate, error) {
+ return appengine.PublicCertificates(g)
+}
+func (g giImpl) RequestID() string {
+ return appengine.RequestID(g)
+}
+func (g giImpl) ServiceAccount() (string, error) {
+ return appengine.ServiceAccount(g)
+}
+func (g giImpl) SignBytes(bytes []byte) (keyName string, signature []byte, err error) {
+ return appengine.SignBytes(g, bytes)
+}
+func (g giImpl) VersionID() string {
+ return appengine.VersionID(g)
+}
+func (g giImpl) Namespace(namespace string) (context.Context, error) {
+ gaeC, err := appengine.Namespace(g, namespace)
+ if err != nil {
+ return nil, err
+ }
+ return Enable(g.ctx, gaeC), nil
+}
+func (g giImpl) Datacenter() string { return appengine.Datacenter() }
M-A Ruel 2015/05/25 17:14:52 Why some one line and other 3 lines? I'd prefer co
iannucci 2015/05/26 18:25:06 I wanted them to all be 1line, but gofmt apparentl
+func (g giImpl) InstanceID() string { return appengine.InstanceID() }
+func (g giImpl) IsDevAppserver() bool { return appengine.IsDevAppServer() }
+func (g giImpl) ServerSoftware() string { return appengine.ServerSoftware() }
+func (g giImpl) IsCapabilityDisabled(err error) bool { return appengine.IsCapabilityDisabled(err) }
+func (g giImpl) IsOverQuota(err error) bool { return appengine.IsOverQuota(err) }
+func (g giImpl) IsTimeoutError(err error) bool { return appengine.IsTimeoutError(err) }

Powered by Google App Engine
This is Rietveld 408576698