| Index: impl/memory/raw_datastore.go
|
| diff --git a/memory/raw_datastore.go b/impl/memory/raw_datastore.go
|
| similarity index 56%
|
| rename from memory/raw_datastore.go
|
| rename to impl/memory/raw_datastore.go
|
| index e6ee65f49448b67ca4a860ea88227d976a0bb7a8..3bf5a05ef42b99b8058c054c177a19960efda2cd 100644
|
| --- a/memory/raw_datastore.go
|
| +++ b/impl/memory/raw_datastore.go
|
| @@ -9,8 +9,7 @@ import (
|
|
|
| "golang.org/x/net/context"
|
|
|
| - "github.com/luci/gae"
|
| - "github.com/luci/gae/helper"
|
| + rds "github.com/luci/gae/service/rawdatastore"
|
| )
|
|
|
| //////////////////////////////////// public ////////////////////////////////////
|
| @@ -18,7 +17,7 @@ import (
|
| // useRDS adds a gae.Datastore implementation to context, accessible
|
| // by gae.GetDS(c)
|
| func useRDS(c context.Context) context.Context {
|
| - return gae.SetRDSFactory(c, func(ic context.Context) gae.RawDatastore {
|
| + return rds.SetFactory(c, func(ic context.Context) rds.Interface {
|
| dsd := cur(ic).Get(memContextDSIdx)
|
|
|
| ns := curGID(ic).namespace
|
| @@ -38,56 +37,56 @@ type dsImpl struct {
|
| c context.Context
|
| }
|
|
|
| -var _ gae.RawDatastore = (*dsImpl)(nil)
|
| +var _ rds.Interface = (*dsImpl)(nil)
|
|
|
| -func (d *dsImpl) DecodeKey(encoded string) (gae.DSKey, error) {
|
| - return helper.NewDSKeyFromEncoded(encoded)
|
| +func (d *dsImpl) DecodeKey(encoded string) (rds.Key, error) {
|
| + return rds.NewKeyFromEncoded(encoded)
|
| }
|
|
|
| -func (d *dsImpl) NewKey(kind, stringID string, intID int64, parent gae.DSKey) gae.DSKey {
|
| - return helper.NewDSKey(globalAppID, d.ns, kind, stringID, intID, parent)
|
| +func (d *dsImpl) NewKey(kind, stringID string, intID int64, parent rds.Key) rds.Key {
|
| + return rds.NewKey(globalAppID, d.ns, kind, stringID, intID, parent)
|
| }
|
|
|
| -func (d *dsImpl) Put(key gae.DSKey, pls gae.DSPropertyLoadSaver) (gae.DSKey, error) {
|
| +func (d *dsImpl) Put(key rds.Key, pls rds.PropertyLoadSaver) (rds.Key, error) {
|
| return d.data.put(d.ns, key, pls)
|
| }
|
|
|
| -func (d *dsImpl) PutMulti(keys []gae.DSKey, plss []gae.DSPropertyLoadSaver) ([]gae.DSKey, error) {
|
| +func (d *dsImpl) PutMulti(keys []rds.Key, plss []rds.PropertyLoadSaver) ([]rds.Key, error) {
|
| return d.data.putMulti(d.ns, keys, plss)
|
| }
|
|
|
| -func (d *dsImpl) Get(key gae.DSKey, pls gae.DSPropertyLoadSaver) error {
|
| +func (d *dsImpl) Get(key rds.Key, pls rds.PropertyLoadSaver) error {
|
| return d.data.get(d.ns, key, pls)
|
| }
|
|
|
| -func (d *dsImpl) GetMulti(keys []gae.DSKey, plss []gae.DSPropertyLoadSaver) error {
|
| +func (d *dsImpl) GetMulti(keys []rds.Key, plss []rds.PropertyLoadSaver) error {
|
| return d.data.getMulti(d.ns, keys, plss)
|
| }
|
|
|
| -func (d *dsImpl) Delete(key gae.DSKey) error {
|
| +func (d *dsImpl) Delete(key rds.Key) error {
|
| return d.data.del(d.ns, key)
|
| }
|
|
|
| -func (d *dsImpl) DeleteMulti(keys []gae.DSKey) error {
|
| +func (d *dsImpl) DeleteMulti(keys []rds.Key) error {
|
| return d.data.delMulti(d.ns, keys)
|
| }
|
|
|
| -func (d *dsImpl) NewQuery(kind string) gae.DSQuery {
|
| +func (d *dsImpl) NewQuery(kind string) rds.Query {
|
| return &queryImpl{ns: d.ns, kind: kind}
|
| }
|
|
|
| -func (d *dsImpl) Run(q gae.DSQuery) gae.RDSIterator {
|
| +func (d *dsImpl) Run(q rds.Query) rds.Iterator {
|
| rq := q.(*queryImpl)
|
| rq = rq.normalize().checkCorrectness(d.ns, false)
|
| return &queryIterImpl{rq}
|
| }
|
|
|
| -func (d *dsImpl) GetAll(q gae.DSQuery, dst *[]gae.DSPropertyMap) ([]gae.DSKey, error) {
|
| +func (d *dsImpl) GetAll(q rds.Query, dst *[]rds.PropertyMap) ([]rds.Key, error) {
|
| // TODO(riannucci): assert that dst is a slice of structs
|
| panic("NOT IMPLEMENTED")
|
| }
|
|
|
| -func (d *dsImpl) Count(q gae.DSQuery) (int, error) {
|
| +func (d *dsImpl) Count(q rds.Query) (int, error) {
|
| return count(d.Run(q.KeysOnly()))
|
| }
|
|
|
| @@ -98,17 +97,17 @@ type txnDsImpl struct {
|
| ns string
|
| }
|
|
|
| -var _ gae.RawDatastore = (*txnDsImpl)(nil)
|
| +var _ rds.Interface = (*txnDsImpl)(nil)
|
|
|
| -func (d *txnDsImpl) DecodeKey(encoded string) (gae.DSKey, error) {
|
| - return helper.NewDSKeyFromEncoded(encoded)
|
| +func (d *txnDsImpl) DecodeKey(encoded string) (rds.Key, error) {
|
| + return rds.NewKeyFromEncoded(encoded)
|
| }
|
|
|
| -func (d *txnDsImpl) NewKey(kind, stringID string, intID int64, parent gae.DSKey) gae.DSKey {
|
| - return helper.NewDSKey(globalAppID, d.ns, kind, stringID, intID, parent)
|
| +func (d *txnDsImpl) NewKey(kind, stringID string, intID int64, parent rds.Key) rds.Key {
|
| + return rds.NewKey(globalAppID, d.ns, kind, stringID, intID, parent)
|
| }
|
|
|
| -func (d *txnDsImpl) Put(key gae.DSKey, pls gae.DSPropertyLoadSaver) (retKey gae.DSKey, err error) {
|
| +func (d *txnDsImpl) Put(key rds.Key, pls rds.PropertyLoadSaver) (retKey rds.Key, err error) {
|
| err = d.data.run(func() (err error) {
|
| retKey, err = d.data.put(d.ns, key, pls)
|
| return
|
| @@ -116,7 +115,7 @@ func (d *txnDsImpl) Put(key gae.DSKey, pls gae.DSPropertyLoadSaver) (retKey gae.
|
| return
|
| }
|
|
|
| -func (d *txnDsImpl) PutMulti(keys []gae.DSKey, plss []gae.DSPropertyLoadSaver) (retKeys []gae.DSKey, err error) {
|
| +func (d *txnDsImpl) PutMulti(keys []rds.Key, plss []rds.PropertyLoadSaver) (retKeys []rds.Key, err error) {
|
| err = d.data.run(func() (err error) {
|
| retKeys, err = d.data.putMulti(d.ns, keys, plss)
|
| return
|
| @@ -124,31 +123,31 @@ func (d *txnDsImpl) PutMulti(keys []gae.DSKey, plss []gae.DSPropertyLoadSaver) (
|
| return
|
| }
|
|
|
| -func (d *txnDsImpl) Get(key gae.DSKey, pls gae.DSPropertyLoadSaver) error {
|
| +func (d *txnDsImpl) Get(key rds.Key, pls rds.PropertyLoadSaver) error {
|
| return d.data.run(func() error {
|
| return d.data.get(d.ns, key, pls)
|
| })
|
| }
|
|
|
| -func (d *txnDsImpl) GetMulti(keys []gae.DSKey, plss []gae.DSPropertyLoadSaver) error {
|
| +func (d *txnDsImpl) GetMulti(keys []rds.Key, plss []rds.PropertyLoadSaver) error {
|
| return d.data.run(func() error {
|
| return d.data.getMulti(d.ns, keys, plss)
|
| })
|
| }
|
|
|
| -func (d *txnDsImpl) Delete(key gae.DSKey) error {
|
| +func (d *txnDsImpl) Delete(key rds.Key) error {
|
| return d.data.run(func() error {
|
| return d.data.del(d.ns, key)
|
| })
|
| }
|
|
|
| -func (d *txnDsImpl) DeleteMulti(keys []gae.DSKey) error {
|
| +func (d *txnDsImpl) DeleteMulti(keys []rds.Key) error {
|
| return d.data.run(func() error {
|
| return d.data.delMulti(d.ns, keys)
|
| })
|
| }
|
|
|
| -func (d *txnDsImpl) Run(q gae.DSQuery) gae.RDSIterator {
|
| +func (d *txnDsImpl) Run(q rds.Query) rds.Iterator {
|
| rq := q.(*queryImpl)
|
| if rq.ancestor == nil {
|
| rq.err = errors.New("memory: queries in transactions only support ancestor queries")
|
| @@ -157,28 +156,28 @@ func (d *txnDsImpl) Run(q gae.DSQuery) gae.RDSIterator {
|
| panic("NOT IMPLEMENTED")
|
| }
|
|
|
| -func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *gae.DSTransactionOptions) error {
|
| +func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *rds.TransactionOptions) error {
|
| return errors.New("datastore: nested transactions are not supported")
|
| }
|
|
|
| -func (d *txnDsImpl) NewQuery(kind string) gae.DSQuery {
|
| +func (d *txnDsImpl) NewQuery(kind string) rds.Query {
|
| return &queryImpl{ns: d.ns, kind: kind}
|
| }
|
|
|
| -func (d *txnDsImpl) GetAll(q gae.DSQuery, dst *[]gae.DSPropertyMap) ([]gae.DSKey, error) {
|
| +func (d *txnDsImpl) GetAll(q rds.Query, dst *[]rds.PropertyMap) ([]rds.Key, error) {
|
| // TODO(riannucci): assert that dst is a slice of structs
|
| panic("NOT IMPLEMENTED")
|
| }
|
|
|
| -func (d *txnDsImpl) Count(q gae.DSQuery) (int, error) {
|
| +func (d *txnDsImpl) Count(q rds.Query) (int, error) {
|
| return count(d.Run(q.KeysOnly()))
|
| }
|
|
|
| -func count(itr gae.RDSIterator) (ret int, err error) {
|
| +func count(itr rds.Iterator) (ret int, err error) {
|
| for _, err = itr.Next(nil); err != nil; _, err = itr.Next(nil) {
|
| ret++
|
| }
|
| - if err == gae.ErrDSQueryDone {
|
| + if err == rds.ErrQueryDone {
|
| err = nil
|
| }
|
| return
|
|
|