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

Unified Diff: impl/prod/raw_datastore.go

Issue 1243323002: Refactor a bit. (Closed) Base URL: https://github.com/luci/gae.git@master
Patch Set: fix golint 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 | « impl/prod/memcache.go ('k') | impl/prod/raw_datastore_type_converter.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: impl/prod/raw_datastore.go
diff --git a/prod/raw_datastore.go b/impl/prod/raw_datastore.go
similarity index 57%
rename from prod/raw_datastore.go
rename to impl/prod/raw_datastore.go
index 94969932ed35e6bf7911313ad9d12271095b6f40..cc25c3773abb9ba20ff8191eab27a17a8ff4c6d4 100644
--- a/prod/raw_datastore.go
+++ b/impl/prod/raw_datastore.go
@@ -6,6 +6,7 @@ package prod
import (
"github.com/luci/gae"
+ rds "github.com/luci/gae/service/rawdatastore"
"golang.org/x/net/context"
"google.golang.org/appengine/datastore"
)
@@ -13,7 +14,7 @@ import (
// useRDS adds a gae.RawDatastore implementation to context, accessible
// by gae.GetDS(c)
func useRDS(c context.Context) context.Context {
- return gae.SetRDSFactory(c, func(ci context.Context) gae.RawDatastore {
+ return rds.SetFactory(c, func(ci context.Context) rds.Interface {
return rdsImpl{ci}
})
}
@@ -22,37 +23,37 @@ func useRDS(c context.Context) context.Context {
type queryImpl struct{ *datastore.Query }
-func (q queryImpl) Distinct() gae.DSQuery {
+func (q queryImpl) Distinct() rds.Query {
return queryImpl{q.Query.Distinct()}
}
-func (q queryImpl) End(c gae.DSCursor) gae.DSQuery {
+func (q queryImpl) End(c rds.Cursor) rds.Query {
return queryImpl{q.Query.End(c.(datastore.Cursor))}
}
-func (q queryImpl) EventualConsistency() gae.DSQuery {
+func (q queryImpl) EventualConsistency() rds.Query {
return queryImpl{q.Query.EventualConsistency()}
}
-func (q queryImpl) KeysOnly() gae.DSQuery {
+func (q queryImpl) KeysOnly() rds.Query {
return queryImpl{q.Query.KeysOnly()}
}
-func (q queryImpl) Limit(limit int) gae.DSQuery {
+func (q queryImpl) Limit(limit int) rds.Query {
return queryImpl{q.Query.Limit(limit)}
}
-func (q queryImpl) Offset(offset int) gae.DSQuery {
+func (q queryImpl) Offset(offset int) rds.Query {
return queryImpl{q.Query.Offset(offset)}
}
-func (q queryImpl) Order(fieldName string) gae.DSQuery {
+func (q queryImpl) Order(fieldName string) rds.Query {
return queryImpl{q.Query.Order(fieldName)}
}
-func (q queryImpl) Start(c gae.DSCursor) gae.DSQuery {
+func (q queryImpl) Start(c rds.Cursor) rds.Query {
return queryImpl{q.Query.Start(c.(datastore.Cursor))}
}
-func (q queryImpl) Ancestor(ancestor gae.DSKey) gae.DSQuery {
+func (q queryImpl) Ancestor(ancestor rds.Key) rds.Query {
return queryImpl{q.Query.Ancestor(dsF2R(ancestor))}
}
-func (q queryImpl) Project(fieldNames ...string) gae.DSQuery {
+func (q queryImpl) Project(fieldNames ...string) rds.Query {
return queryImpl{q.Query.Project(fieldNames...)}
}
-func (q queryImpl) Filter(filterStr string, value interface{}) gae.DSQuery {
+func (q queryImpl) Filter(filterStr string, value interface{}) rds.Query {
return queryImpl{q.Query.Filter(filterStr, value)}
}
@@ -60,13 +61,13 @@ func (q queryImpl) Filter(filterStr string, value interface{}) gae.DSQuery {
type iteratorImpl struct{ *datastore.Iterator }
-var _ gae.RDSIterator = iteratorImpl{}
+var _ rds.Iterator = iteratorImpl{}
-func (i iteratorImpl) Cursor() (gae.DSCursor, error) {
+func (i iteratorImpl) Cursor() (rds.Cursor, error) {
return i.Iterator.Cursor()
}
-func (i iteratorImpl) Next(pls gae.DSPropertyLoadSaver) (gae.DSKey, error) {
+func (i iteratorImpl) Next(pls rds.PropertyLoadSaver) (rds.Key, error) {
return dsR2FErr(i.Iterator.Next(&typeFilter{pls}))
}
@@ -75,15 +76,15 @@ func (i iteratorImpl) Next(pls gae.DSPropertyLoadSaver) (gae.DSKey, error) {
type rdsImpl struct{ context.Context }
// NewKeyer
-func (d rdsImpl) NewKey(kind, stringID string, intID int64, parent gae.DSKey) gae.DSKey {
+func (d rdsImpl) NewKey(kind, stringID string, intID int64, parent rds.Key) rds.Key {
return dsR2F(datastore.NewKey(d, kind, stringID, intID, dsF2R(parent)))
}
-func (rdsImpl) DecodeKey(encoded string) (gae.DSKey, error) {
+func (rdsImpl) DecodeKey(encoded string) (rds.Key, error) {
return dsR2FErr(datastore.DecodeKey(encoded))
}
-func multiWrap(os []gae.DSPropertyLoadSaver) []datastore.PropertyLoadSaver {
+func multiWrap(os []rds.PropertyLoadSaver) []datastore.PropertyLoadSaver {
ret := make([]datastore.PropertyLoadSaver, len(os))
for i, pls := range os {
ret[i] = &typeFilter{pls}
@@ -91,45 +92,45 @@ func multiWrap(os []gae.DSPropertyLoadSaver) []datastore.PropertyLoadSaver {
return ret
}
-func (d rdsImpl) Delete(k gae.DSKey) error { return datastore.Delete(d, dsF2R(k)) }
-func (d rdsImpl) Get(key gae.DSKey, dst gae.DSPropertyLoadSaver) error {
+func (d rdsImpl) Delete(k rds.Key) error { return datastore.Delete(d, dsF2R(k)) }
+func (d rdsImpl) Get(key rds.Key, dst rds.PropertyLoadSaver) error {
return datastore.Get(d, dsF2R(key), &typeFilter{dst})
}
-func (d rdsImpl) Put(key gae.DSKey, src gae.DSPropertyLoadSaver) (gae.DSKey, error) {
+func (d rdsImpl) Put(key rds.Key, src rds.PropertyLoadSaver) (rds.Key, error) {
return dsR2FErr(datastore.Put(d, dsF2R(key), &typeFilter{src}))
}
-func (d rdsImpl) DeleteMulti(ks []gae.DSKey) error {
+func (d rdsImpl) DeleteMulti(ks []rds.Key) error {
return gae.FixError(datastore.DeleteMulti(d, dsMF2R(ks)))
}
-func (d rdsImpl) GetMulti(ks []gae.DSKey, plss []gae.DSPropertyLoadSaver) error {
+func (d rdsImpl) GetMulti(ks []rds.Key, plss []rds.PropertyLoadSaver) error {
return gae.FixError(datastore.GetMulti(d, dsMF2R(ks), multiWrap(plss)))
}
-func (d rdsImpl) PutMulti(key []gae.DSKey, plss []gae.DSPropertyLoadSaver) ([]gae.DSKey, error) {
+func (d rdsImpl) PutMulti(key []rds.Key, plss []rds.PropertyLoadSaver) ([]rds.Key, error) {
ks, err := datastore.PutMulti(d, dsMF2R(key), multiWrap(plss))
return dsMR2F(ks), gae.FixError(err)
}
// DSQueryer
-func (d rdsImpl) NewQuery(kind string) gae.DSQuery {
+func (d rdsImpl) NewQuery(kind string) rds.Query {
return queryImpl{datastore.NewQuery(kind)}
}
-func (d rdsImpl) Run(q gae.DSQuery) gae.RDSIterator {
+func (d rdsImpl) Run(q rds.Query) rds.Iterator {
return iteratorImpl{q.(queryImpl).Query.Run(d)}
}
-func (d rdsImpl) Count(q gae.DSQuery) (int, error) {
+func (d rdsImpl) Count(q rds.Query) (int, error) {
return q.(queryImpl).Query.Count(d)
}
-func (d rdsImpl) GetAll(q gae.DSQuery, dst *[]gae.DSPropertyMap) ([]gae.DSKey, error) {
+func (d rdsImpl) GetAll(q rds.Query, dst *[]rds.PropertyMap) ([]rds.Key, error) {
fakeDst := []datastore.PropertyList(nil)
ks, err := q.(queryImpl).GetAll(d, &fakeDst)
if err != nil {
return nil, err
}
- *dst = make([]gae.DSPropertyMap, len(fakeDst))
+ *dst = make([]rds.PropertyMap, len(fakeDst))
for i, pl := range fakeDst {
- (*dst)[i] = gae.DSPropertyMap{}
+ (*dst)[i] = rds.PropertyMap{}
if err := (&typeFilter{(*dst)[i]}).Load(pl); err != nil {
return nil, err
}
@@ -138,7 +139,7 @@ func (d rdsImpl) GetAll(q gae.DSQuery, dst *[]gae.DSPropertyMap) ([]gae.DSKey, e
}
// Transactioner
-func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *gae.DSTransactionOptions) error {
+func (d rdsImpl) RunInTransaction(f func(c context.Context) error, opts *rds.TransactionOptions) error {
ropts := (*datastore.TransactionOptions)(opts)
return datastore.RunInTransaction(d, f, ropts)
}
« no previous file with comments | « impl/prod/memcache.go ('k') | impl/prod/raw_datastore_type_converter.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698