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

Side by Side Diff: impl/memory/datastore.go

Issue 1309803004: Add transaction buffer filter. (Closed) Base URL: https://github.com/luci/gae.git@add_query_support
Patch Set: Fix builtin+ancestor+multi-eq+multiIterator bug, add more txnBuf test Created 5 years, 2 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
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 memory 5 package memory
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 10
(...skipping 11 matching lines...) Expand all
22 dsd := cur(ic).Get(memContextDSIdx) 22 dsd := cur(ic).Get(memContextDSIdx)
23 23
24 ns := curGID(ic).namespace 24 ns := curGID(ic).namespace
25 if x, ok := dsd.(*dataStoreData); ok { 25 if x, ok := dsd.(*dataStoreData); ok {
26 return &dsImpl{x, ns, ic} 26 return &dsImpl{x, ns, ic}
27 } 27 }
28 return &txnDsImpl{dsd.(*txnDataStoreData), ns} 28 return &txnDsImpl{dsd.(*txnDataStoreData), ns}
29 }) 29 })
30 } 30 }
31 31
32 // NewDatastore creates a new standalone memory implementation of the datastore.
33 func NewDatastore(ns string) ds.RawInterface {
34 return &dsImpl{newDataStoreData(), ns, context.Background()}
35 }
36
32 //////////////////////////////////// dsImpl //////////////////////////////////// 37 //////////////////////////////////// dsImpl ////////////////////////////////////
33 38
34 // dsImpl exists solely to bind the current c to the datastore data. 39 // dsImpl exists solely to bind the current c to the datastore data.
35 type dsImpl struct { 40 type dsImpl struct {
36 data *dataStoreData 41 data *dataStoreData
37 ns string 42 ns string
38 c context.Context 43 c context.Context
39 } 44 }
40 45
41 var _ ds.RawInterface = (*dsImpl)(nil) 46 var _ ds.RawInterface = (*dsImpl)(nil)
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 return countQuery(fq, d.ns, true, d.data.snap, d.data.snap) 186 return countQuery(fq, d.ns, true, d.data.snap, d.data.snap)
182 } 187 }
183 188
184 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error { 189 func (*txnDsImpl) RunInTransaction(func(c context.Context) error, *ds.Transactio nOptions) error {
185 return errors.New("datastore: nested transactions are not supported") 190 return errors.New("datastore: nested transactions are not supported")
186 } 191 }
187 192
188 func (*txnDsImpl) Testable() ds.Testable { 193 func (*txnDsImpl) Testable() ds.Testable {
189 return nil 194 return nil
190 } 195 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698