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

Unified Diff: go/src/infra/gae/libs/gae/prod/datastore_key.go

Issue 1230303003: Revert "Refactor current GAE abstraction library to be free of the SDK*" (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « go/src/infra/gae/libs/gae/prod/context.go ('k') | go/src/infra/gae/libs/gae/prod/doc.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: go/src/infra/gae/libs/gae/prod/datastore_key.go
diff --git a/go/src/infra/gae/libs/gae/prod/datastore_key.go b/go/src/infra/gae/libs/gae/prod/datastore_key.go
deleted file mode 100644
index 2b823114f3c6006d2124ba715420fbea9d1d47fe..0000000000000000000000000000000000000000
--- a/go/src/infra/gae/libs/gae/prod/datastore_key.go
+++ /dev/null
@@ -1,82 +0,0 @@
-// 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 prod
-
-import (
- "infra/gae/libs/gae"
- "infra/gae/libs/gae/helper"
-
- "google.golang.org/appengine/datastore"
-)
-
-type dsKeyImpl struct {
- *datastore.Key
-}
-
-var _ gae.DSKey = dsKeyImpl{}
-
-func (k dsKeyImpl) Equal(other gae.DSKey) bool { return k.Key.Equal(dsF2R(other)) }
-func (k dsKeyImpl) Parent() gae.DSKey { return dsR2F(k.Key.Parent()) }
-func (k dsKeyImpl) Root() gae.DSKey { return helper.DSKeyRoot(k) }
-func (k dsKeyImpl) Valid(ns string, allowSpecial bool) bool {
- return helper.DSKeyValid(k, ns, allowSpecial)
-}
-
-// dsR2F (DS real-to-fake) converts an SDK Key to a gae.DSKey
-func dsR2F(k *datastore.Key) gae.DSKey {
- return dsKeyImpl{k}
-}
-
-// dsR2FErr (DS real-to-fake with error) acts like dsR2F, but is for wrapping function
-// invocations which return (*Key, error). e.g.
-//
-// return dsR2FErr(datastore.Put(...))
-//
-// instead of:
-//
-// k, err := datastore.Put(...)
-// if err != nil {
-// return nil, err
-// }
-// return dsR2F(k), nil
-func dsR2FErr(k *datastore.Key, err error) (gae.DSKey, error) {
- if err != nil {
- return nil, err
- }
- return dsR2F(k), nil
-}
-
-// dsF2R (DS fake-to-real) converts a DSKey back to an SDK *Key.
-func dsF2R(k gae.DSKey) *datastore.Key {
- if rkey, ok := k.(dsKeyImpl); ok {
- return rkey.Key
- }
- // we should always hit the fast case above, but just in case, safely round
- // trip through the proto encoding.
- rkey, err := datastore.DecodeKey(helper.DSKeyEncode(k))
- if err != nil {
- panic(err)
- }
- return rkey
-}
-
-// dsMR2F (DS multi-real-to-fake) converts a slice of SDK keys to their wrapped
-// types.
-func dsMR2F(ks []*datastore.Key) []gae.DSKey {
- ret := make([]gae.DSKey, len(ks))
- for i, k := range ks {
- ret[i] = dsR2F(k)
- }
- return ret
-}
-
-// dsMF2R (DS multi-fake-to-fake) converts a slice of wrapped keys to SDK keys.
-func dsMF2R(ks []gae.DSKey) []*datastore.Key {
- ret := make([]*datastore.Key, len(ks))
- for i, k := range ks {
- ret[i] = dsF2R(k)
- }
- return ret
-}
« no previous file with comments | « go/src/infra/gae/libs/gae/prod/context.go ('k') | go/src/infra/gae/libs/gae/prod/doc.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698