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

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

Issue 1957953002: Add cloud datastore implementation. (Closed) Base URL: https://chromium.googlesource.com/external/github.com/luci/gae@master
Patch Set: Adjust minimum coverage. Created 4 years, 5 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/cloud/datastore_test.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package cloud
6
7 import (
8 "errors"
9 "time"
10
11 infoS "github.com/luci/gae/service/info"
12
13 "golang.org/x/net/context"
14 )
15
16 var errNotImplemented = errors.New("not implemented")
17
18 // cloudInfo is a reconstruction of the info service for the cloud API.
19 //
20 // It will return information sufficent for datastore operation.
21 type infoState struct {
22 // namespace is the current namesapce, or the empty string for no namesp ace.
23 namespace string
24 }
25
26 var infoStateKey = "*cloud.infoState"
27
28 func getInfoState(c context.Context) *infoState {
29 if is, ok := c.Value(&infoStateKey).(*infoState); ok {
30 return is
31 }
32 panic("no info state in Context")
33 }
34
35 func (ci *infoState) use(c context.Context) context.Context {
36 return context.WithValue(c, &infoStateKey, ci)
37 }
38
39 func (ci *infoState) derive(mutate func(*infoState)) *infoState {
40 dci := *ci
41 mutate(&dci)
42 return &dci
43 }
44
45 type infoService struct {
46 *infoState
47
48 ic context.Context
49 }
50
51 func useInfo(c context.Context) context.Context {
52 var baseInfoState infoState
53 c = baseInfoState.use(c)
54
55 return infoS.SetFactory(c, func(ic context.Context) infoS.RawInterface {
56 return &infoService{
57 infoState: getInfoState(ic),
58 ic: ic,
59 }
60 })
61 }
62
63 func (i *infoService) AppID() string { panic(errNotImplemented) }
64 func (i *infoService) FullyQualifiedAppID() string { return "" }
65 func (i *infoService) GetNamespace() (string, bool) { return i.namespace, (i.nam espace != "") }
66
67 func (i *infoService) Datacenter() string { panic(errNotImplemented) }
68 func (i *infoService) DefaultVersionHostname() string { panic(errNotImplemented) }
69 func (i *infoService) InstanceID() string { panic(errNotImplemented) }
70 func (i *infoService) IsDevAppServer() bool { panic(errNotImplemented) }
71 func (i *infoService) IsOverQuota(err error) bool { panic(errNotImplemented) }
72 func (i *infoService) IsTimeoutError(err error) bool { panic(errNotImplemented) }
73 func (i *infoService) ModuleHostname(module, version, instance string) (string, error) {
74 return "", errNotImplemented
75 }
76 func (i *infoService) ModuleName() string { panic(errNotImplemented ) }
77 func (i *infoService) RequestID() string { panic(errNotImplemented ) }
78 func (i *infoService) ServerSoftware() string { panic(errNotImplemented ) }
79 func (i *infoService) ServiceAccount() (string, error) { return "", errNotImplem ented }
80 func (i *infoService) VersionID() string { panic(errNotImplemented ) }
81
82 func (i *infoService) Namespace(namespace string) (context.Context, error) {
83 return i.MustNamespace(namespace), nil
84 }
85
86 func (i *infoService) MustNamespace(namespace string) context.Context {
87 return i.derive(func(ci *infoState) {
88 ci.namespace = namespace
89 }).use(i.ic)
90 }
91
92 func (i *infoService) AccessToken(scopes ...string) (token string, expiry time.T ime, err error) {
93 return "", time.Time{}, errNotImplemented
94 }
95
96 func (i *infoService) PublicCertificates() ([]infoS.Certificate, error) {
97 return nil, errNotImplemented
98 }
99
100 func (i *infoService) SignBytes(bytes []byte) (keyName string, signature []byte, err error) {
101 return "", nil, errNotImplemented
102 }
103
104 func (i *infoService) Testable() infoS.Testable { return nil }
OLDNEW
« no previous file with comments | « impl/cloud/datastore_test.go ('k') | impl/prod/raw_datastore.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698