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

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

Issue 1490243004: Make appengine connection explicitly owned by impl/prod. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix other services too Created 5 years 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/prod/context.go ('k') | impl/prod/everything_test.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 ds "github.com/luci/gae/service/datastore" 8 ds "github.com/luci/gae/service/datastore"
9 "github.com/luci/luci-go/common/errors" 9 "github.com/luci/luci-go/common/errors"
10 "golang.org/x/net/context" 10 "golang.org/x/net/context"
(...skipping 23 matching lines...) Expand all
34 for ; k != nil; k = k.Parent() { 34 for ; k != nil; k = k.Parent() {
35 count-- 35 count--
36 toks[count].Kind = k.Kind() 36 toks[count].Kind = k.Kind()
37 toks[count].StringID = k.StringID() 37 toks[count].StringID = k.StringID()
38 toks[count].IntID = k.IntID() 38 toks[count].IntID = k.IntID()
39 } 39 }
40 return ds.NewKeyToks(aid, ns, toks) 40 return ds.NewKeyToks(aid, ns, toks)
41 } 41 }
42 42
43 // dsF2R (DS fake-to-real) converts a DSKey back to an SDK *Key. 43 // dsF2R (DS fake-to-real) converts a DSKey back to an SDK *Key.
44 func dsF2R(ctx context.Context, k *ds.Key) (*datastore.Key, error) { 44 func dsF2R(aeCtx context.Context, k *ds.Key) (*datastore.Key, error) {
Vadim Sh. 2015/12/03 00:49:57 how do you feel about adding a typedef for AE cont
45 if k == nil { 45 if k == nil {
46 return nil, nil 46 return nil, nil
47 } 47 }
48 48
49 // drop aid. 49 // drop aid.
50 _, ns, toks := k.Split() 50 _, ns, toks := k.Split()
51 err := error(nil) 51 err := error(nil)
52 » ctx, err = appengine.Namespace(ctx, ns) 52 » aeCtx, err = appengine.Namespace(aeCtx, ns)
53 if err != nil { 53 if err != nil {
54 return nil, err 54 return nil, err
55 } 55 }
56 56
57 » ret := datastore.NewKey(ctx, toks[0].Kind, toks[0].StringID, toks[0].Int ID, nil) 57 » ret := datastore.NewKey(aeCtx, toks[0].Kind, toks[0].StringID, toks[0].I ntID, nil)
58 for _, t := range toks[1:] { 58 for _, t := range toks[1:] {
59 » » ret = datastore.NewKey(ctx, t.Kind, t.StringID, t.IntID, ret) 59 » » ret = datastore.NewKey(aeCtx, t.Kind, t.StringID, t.IntID, ret)
60 } 60 }
61 61
62 return ret, nil 62 return ret, nil
63 } 63 }
64 64
65 // dsMF2R (DS multi-fake-to-fake) converts a slice of wrapped keys to SDK keys. 65 // dsMF2R (DS multi-fake-to-fake) converts a slice of wrapped keys to SDK keys.
66 func dsMF2R(ctx context.Context, ks []*ds.Key) ([]*datastore.Key, error) { 66 func dsMF2R(aeCtx context.Context, ks []*ds.Key) ([]*datastore.Key, error) {
67 lme := errors.NewLazyMultiError(len(ks)) 67 lme := errors.NewLazyMultiError(len(ks))
68 ret := make([]*datastore.Key, len(ks)) 68 ret := make([]*datastore.Key, len(ks))
69 err := error(nil) 69 err := error(nil)
70 for i, k := range ks { 70 for i, k := range ks {
71 » » ret[i], err = dsF2R(ctx, k) 71 » » ret[i], err = dsF2R(aeCtx, k)
72 lme.Assign(i, err) 72 lme.Assign(i, err)
73 } 73 }
74 return ret, lme.Get() 74 return ret, lme.Get()
75 } 75 }
OLDNEW
« no previous file with comments | « impl/prod/context.go ('k') | impl/prod/everything_test.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698